summaryrefslogtreecommitdiff
path: root/hw/kdrive/sis530/sis.h
blob: a1dc7bab7073d759cb0a937c4275b7b5bdb832c4 (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
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
/*
 * $Id$
 *
 * Copyright © 1999 Keith Packard
 *
 * 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 Keith Packard not be used in
 * advertising or publicity pertaining to distribution of the software without
 * specific, written prior permission.  Keith Packard makes no
 * representations about the suitability of this software for any purpose.  It
 * is provided "as is" without express or implied warranty.
 *
 * KEITH PACKARD DISCLAIMS ALL WARRANTIES WITH REGARD TO THIS SOFTWARE,
 * INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS, IN NO
 * EVENT SHALL KEITH PACKARD 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.
 */
/* $XFree86: xc/programs/Xserver/hw/kdrive/sis530/sis.h,v 1.1 1999/11/19 13:53:58 hohndel Exp $ */

#ifndef _SIS_H_
#define _SIS_H_
#include "kdrive.h"
#include <stdio.h>
#include <unistd.h>
#include <sys/mman.h>
#include <asm/io.h>
#include <stdio.h>

/*
 *  Linear Addressing		000 0000 - 0ff ffff (16m)
 *  Image data transfer		100 0000 - 100 7fff (32k)
 *  Empty			100 8000 - 100 81ff
 *  MMIO registers		100 8200 - 100 8480
 *
 * We don't care about the image transfer or PCI regs, so
 * this structure starts at the MMIO regs
 */
    
typedef volatile CARD32 VOL32;
typedef volatile CARD16 VOL16;
typedef volatile CARD8 VOL8;

#define SIS_MMIO_OFFSET	0x8200

typedef struct _sis530General {
    VOL32	src_base;		/* 8200 */
    VOL16	src_pitch;		/* 8204 */
    VOL16	_pad0;			/* 8206 */
    VOL16	src_y;			/* 8208 */
    VOL16	src_x;			/* 820a */
    VOL16	dst_y;			/* 820c */
    VOL16	dst_x;			/* 820e */
    VOL32	dst_base;		/* 8210 */
    VOL16	dst_pitch;		/* 8214 */
    VOL16	dst_height;		/* 8216 */
    VOL16	rect_width;		/* 8218 */
    VOL16	rect_height;		/* 821a */
    VOL32	pattern_fg;		/* 821c */
    VOL32	pattern_bg;		/* 8220 */
    VOL32	src_fg;			/* 8224 */
    VOL32	src_bg;			/* 8228 */
    VOL8	mask[8];		/* 822c */
    VOL16	clip_left;		/* 8234 */
    VOL16	clip_top;		/* 8236 */
    VOL16	clip_right;		/* 8238 */
    VOL16	clip_bottom;		/* 823a */
    VOL32	command;		/* 823c */
    VOL32	status;			/* 8240 */
    VOL8	_pad1[0xbc];		/* 8244 */
    VOL8	pattern[256];		/* 8300 */
					/* 8400 */
} SisGeneral;

typedef struct _sis530Line {
    VOL8	_pad0[8];		/* 8200 */
    VOL16	x0;			/* 8208 */
    VOL16	y0;			/* 820a */
    VOL16	x1;			/* 820c */
    VOL16	y1;			/* 820e */
    VOL32	dst_base;		/* 8210 */
    VOL16	dst_pitch;		/* 8214 */
    VOL16	dst_height;		/* 8216 */
    VOL16	count;			/* 8218 */
    VOL16	style_period;		/* 821a */
    VOL32	fg;			/* 821c */
    VOL32	bg;			/* 8220 */
    VOL8	_pad1[8];		/* 8224 */
    VOL32	style0;			/* 822c */
    VOL32	style1;			/* 8228 */
    VOL16	clip_left;		/* 8234 */
    VOL16	clip_top;		/* 8236 */
    VOL16	clip_right;		/* 8238 */
    VOL16	clip_bottom;		/* 823a */
    VOL32	command;		/* 823c */
    VOL32	status;			/* 8240 */
    VOL8	_pad2[0xbc];		/* 8244 */
    struct {
	VOL16	x;
	VOL16	y;
    }		data[96];		/* 8300 */
					/* 8480 */
} SisLine;

typedef struct _sis530Transparent {
    VOL32	src_base;		/* 8200 */
    VOL16	src_pitch;		/* 8204 */
    VOL16	_pad0;			/* 8206 */
    VOL16	src_y;			/* 8208 */
    VOL16	src_x;			/* 820a */
    VOL16	dst_y;			/* 820c */
    VOL16	dst_x;			/* 820e */
    VOL32	dst_base;		/* 8210 */
    VOL16	dst_pitch;		/* 8214 */
    VOL16	dst_height;		/* 8216 */
    VOL16	rect_width;		/* 8218 */
    VOL16	rect_height;		/* 821a */
    VOL32	dst_key_high;		/* 821c */
    VOL32	dst_key_low;		/* 8220 */
    VOL32	src_key_high;		/* 8224 */
    VOL32	src_key_low;		/* 8228 */
    VOL8	_pad1[8];		/* 822c */
    VOL16	clip_left;		/* 8234 */
    VOL16	clip_top;		/* 8236 */
    VOL16	clip_right;		/* 8238 */
    VOL16	clip_bottom;		/* 823a */
    VOL32	command;		/* 823c */
    VOL32	status;			/* 8240 */
					/* 8244 */
} SisTransparent;

typedef struct _sis530Multiple {
    VOL8	_pad0[8];		/* 8200 */
    VOL16	count;			/* 8208 */
    VOL16	y;			/* 820a */
    VOL16	x0_start;		/* 820c */
    VOL16	x0_end;			/* 820e */
    VOL32	dst_base;		/* 8210 */
    VOL16	dst_pitch;		/* 8214 */
    VOL16	dst_height;		/* 8216 */
    VOL8	_pad1[4];		/* 8218 */
    VOL32	fg;			/* 821c */
    VOL32	bg;			/* 8220 */
    VOL8	_pad2[8];		/* 8224 */
    VOL8	mask[8];		/* 822c */
    VOL16	clip_left;		/* 8234 */
    VOL16	clip_top;		/* 8236 */
    VOL16	clip_right;		/* 8238 */
    VOL16	clip_bottom;		/* 823a */
    VOL32	command;		/* 823c */
    VOL32	status;			/* 8240 */
    VOL16	x1_start;		/* 8244 */
    VOL16	x1_end;			/* 8246 */
    VOL8	_pad3[0xb8];		/* 8248 */
    VOL8	pattern[64];		/* 8300 */
    struct {
	VOL16	x_start;
	VOL16	y_end;
    }		data[80];		/* 8340 */
					/* 8480 */
} SisMultiple;

typedef struct _sis530Trapezoid {
    VOL8	_pad0[8];		/* 8200 */
    VOL16	height;			/* 8208 */
    VOL16	y;			/* 820a */
    VOL16	left_x;			/* 820c */
    VOL16	right_x;	    	/* 820e */
    VOL32	dst_base;		/* 8210 */
    VOL16	dst_pitch;		/* 8214 */
    VOL16	dst_height;		/* 8216 */
    VOL8	_pad1[4];    		/* 8218 */
    VOL32	fg;			/* 821c */
    VOL32	bg;			/* 8220 */
    VOL8	_pad2[8];		/* 8224 */
    VOL8	mask[8];		/* 822c */
    VOL16	clip_left;		/* 8234 */
    VOL16	clip_top;		/* 8236 */
    VOL16	clip_right;		/* 8238 */
    VOL16	clip_bottom;		/* 823a */
    VOL32	command;		/* 823c */
    VOL32	status;			/* 8240 */
    VOL16	left_dx;		/* 8244 */
    VOL16	left_dy;		/* 8246 */
    VOL16	right_dx;		/* 8248 */
    VOL16	right_dy;		/* 824a */
    VOL32	left_error;		/* 824c */
    VOL32	right_error;		/* 8250 */
					/* 8254 */
} SisTrapezoid;

typedef struct _sis530 {
    union {
	SisGeneral	general;
	SisLine		line;
	SisTransparent	transparent;
	SisMultiple	multiple;
	SisTrapezoid	trapezoid;
    } u;
} SisRec, *SisPtr;

typedef struct _sisCursor {
    int		width, height;
    int		xhot, yhot;
    Bool	has_cursor;
    CursorPtr	pCursor;
} SisCursor;

#define SIS_CURSOR_WIDTH    64
#define SIS_CURSOR_HEIGHT   64

typedef struct _sisClock {
    CARD32	vclk_numerator;
    BOOL	vclk_divide_by_2;
    CARD32	vclk_denominator;
    CARD32	vclk_post_scale;
    BOOL	vclk_post_scale_2;
    BOOL	high_speed_dac;
} SisClockRec, *SisClockPtr;

typedef struct _crtc {

    union {
	struct {
	    CARD8   _io_address_select	    : 1;
	    CARD8   _display_ram_enable	    : 1;
	    CARD8   _clock_select	    : 2;
	    CARD8			    : 1;
	    CARD8   _odd_even_page	    : 1;
	    CARD8   _h_sync_polarity	    : 1;
	    CARD8   _v_sync_polarity	    : 1;
	} _misc_output_s;
	CARD8	_misc_output;
    } _misc_output_u;    			    /* 3CC/3C2 */

#define misc_output	    _misc_output_u._misc_output
#define io_address_select   _misc_output_u._misc_output_s._io_address_select
#define display_ram_enable  _misc_output_u._misc_output_s._display_ram_enable
#define clock_select	    _misc_output_u._misc_output_s._clock_select
#define odd_even_page	    _misc_output_u._misc_output_s._odd_even_page
#define h_sync_polarity	    _misc_output_u._misc_output_s._h_sync_polarity
#define v_sync_polarity	    _misc_output_u._misc_output_s._v_sync_polarity
    
    CARD8   h_total_0_7;			    /* CR0 */
    CARD8   h_display_end_0_7;			    /* CR1 */
    CARD8   h_blank_start_0_7;			    /* CR2 */
    union {
	struct {
	    CARD8   _h_blank_end_0_4  	    : 5;
	    CARD8   _display_skew	    : 2;
	    CARD8			    : 1;
	} _h_blank_end_s;
	CARD8   __h_blank_end;			    /* CR3 */
    } _h_blank_end_u;
#define h_blank_end_0_4 _h_blank_end_u._h_blank_end_s._h_blank_end_0_4
#define display_skew	_h_blank_end_u._h_blank_end_s._display_skew
#define _h_blank_end	_h_blank_end_u.__h_blank_end
    
    CARD8   h_sync_start_0_7;			    /* CR4 */
    
    union {
	struct {
	    CARD8   _h_sync_end_0_4    	    : 5;
	    CARD8   _horizontal_skew	    : 2;
	    CARD8   _h_blank_end_5	    : 1;
	} _h_sync_end_s;
        CARD8   __h_sync_end;			    /* CR5 */
    } _h_sync_end_u;

#define h_sync_end_0_4	_h_sync_end_u._h_sync_end_s._h_sync_end_0_4
#define horizontal_skew	_h_sync_end_u._h_sync_end_s._horizontal_skew
#define h_blank_end_5	_h_sync_end_u._h_sync_end_s._h_blank_end_5
#define _h_sync_end	_h_sync_end_u.__h_sync_end
    
    CARD8   v_total_0_7;			    /* CR6 */
    
    union {
	struct {
	    CARD8   _v_total_8		    : 1;
	    CARD8   _v_display_end_8	    : 1;
	    CARD8   _v_retrace_start_8	    : 1;
	    CARD8   _v_blank_start_8	    : 1;
	    CARD8   _line_compare_8	    : 1;
	    CARD8   _v_total_9		    : 1;
	    CARD8   _v_display_end_9	    : 1;
	    CARD8   _v_retrace_start_9	    : 1;
	} _crtc_overflow_s;
	CARD8	_crtc_overflow;			    /* CR7 */
    } _crtc_overflow_u;

#define v_total_8	    _crtc_overflow_u._crtc_overflow_s._v_total_8
#define v_display_end_8	    _crtc_overflow_u._crtc_overflow_s._v_display_end_8
#define v_retrace_start_8   _crtc_overflow_u._crtc_overflow_s._v_retrace_start_8
#define v_blank_start_8	    _crtc_overflow_u._crtc_overflow_s._v_blank_start_8
#define line_compare_8	    _crtc_overflow_u._crtc_overflow_s._line_compare_8
#define v_total_9	    _crtc_overflow_u._crtc_overflow_s._v_total_9
#define v_display_end_9	    _crtc_overflow_u._crtc_overflow_s._v_display_end_9
#define v_retrace_start_9   _crtc_overflow_u._crtc_overflow_s._v_retrace_start_9
#define crtc_overflow	    _crtc_overflow_u._crtc_overflow

    CARD8   preset_row_scan;			    /* CR8 (unused) */

    union {
	struct {
	    CARD8   _max_scan_line	    : 5;
	    CARD8   _v_blank_start_9	    : 1;
	    CARD8   _line_compare_9	    : 1;
	    CARD8   _double_scan		    : 1;
	} _max_scan_line_s;
	CARD8   __max_scan_line;		    /* CR9 */
    } _max_scan_line_u;

#define max_scan_line	_max_scan_line_u._max_scan_line_s._max_scan_line
#define v_blank_start_9	_max_scan_line_u._max_scan_line_s._v_blank_start_9
#define line_compare_9	_max_scan_line_u._max_scan_line_s._line_compare_9
#define double_scan	_max_scan_line_u._max_scan_line_s._double_scan
#define _max_scan_line	_max_scan_line_u.__max_scan_line
    
    CARD8   cursor_start;
    CARD8   cursor_end;

    CARD8   start_address_8_15;			    /* CRC */
    CARD8   start_address_0_7;			    /* CRD */

    CARD8   cursor_loc_high;
    CARD8   cursor_loc_low;

    CARD8   v_retrace_start_0_7;		    /* CR10 */
    union {
	struct {
	    CARD8   _v_retrace_end_0_3	    : 4;
	    CARD8   _clear_v_retrace_int	    : 1;
	    CARD8   _disable_v_retrace_int   : 1;
	    CARD8   _refresh_cycle_select    : 1;
	    CARD8   _lock_crtc		    : 1;
	} _v_retrace_end_s;
	CARD8   __v_retrace_end;		    /* CR11 */
    } _v_retrace_end_u;
    
#define v_retrace_end_0_3	_v_retrace_end_u._v_retrace_end_s._v_retrace_end_0_3
#define clear_v_retrace_int	_v_retrace_end_u._v_retrace_end_s._clear_v_retrace_int
#define disable_v_retrace_int	_v_retrace_end_u._v_retrace_end_s._disable_v_retrace_int
#define refresh_cycle_select	_v_retrace_end_u._v_retrace_end_s._refresh_cycle_select
#define lock_crtc		_v_retrace_end_u._v_retrace_end_s._lock_crtc
#define _v_retrace_end		_v_retrace_end_u.__v_retrace_end
    
    CARD8   v_display_end_0_7;			    /* CR12 */
    
    CARD8   screen_off_0_7;			    /* CR13 */
    
    union {
	struct {
	    CARD8   _underline_location	    : 5;
	    CARD8   _count_by_four	    : 1;
	    CARD8   _doubleword_mode	    : 1;
	    CARD8			    : 1;
	} _underline_location_s;
	CARD8   __underline_location;		    /* CR14 */
    } _underline_location_u;

#define underline_location  _underline_location_u._underline_location_s._underline_location
#define count_by_four	    _underline_location_u._underline_location_s._count_by_four
#define doubleword_mode	    _underline_location_u._underline_location_s._doubleword_mode
#define _underline_location _underline_location_u.__underline_location
    
    CARD8   v_blank_start_0_7;			    /* CR15 */
    CARD8   v_blank_end_0_7;			    /* CR16 */

    union {
	struct {
	    CARD8   _two_bk_cga		    : 1;
	    CARD8   _four_bk_cga	    : 1;
	    CARD8   _v_total_double	    : 1;
	    CARD8   _count_by_two	    : 1;
	    CARD8			    : 1;
	    CARD8   _address_wrap	    : 1;
	    CARD8   _byte_mode		    : 1;
	    CARD8   _hardware_reset	    : 1;
	} _crtc_mode_s;
	CARD8   _crtc_mode;			    /* CR17 */
    } _crtc_mode_u;

#define crtc_mode	_crtc_mode_u._crtc_mode
#define two_bk_cga	_crtc_mode_u._crtc_mode_s._two_bk_cga
#define four_bk_cga	_crtc_mode_u._crtc_mode_s._four_bk_cga
#define v_total_double	_crtc_mode_u._crtc_mode_s._v_total_double
#define count_by_two	_crtc_mode_u._crtc_mode_s._count_by_two
#define address_wrap	_crtc_mode_u._crtc_mode_s._address_wrap
#define byte_mode	_crtc_mode_u._crtc_mode_s._byte_mode
#define hardware_reset	_crtc_mode_u._crtc_mode_s._hardware_reset

    CARD8   line_compare_0_7;			    /* CR18 (unused) */

    union {
	struct {
	    CARD8	_graphics_mode_enable	: 1;
	    CARD8	_attribute_byte_mda	: 1;
	    CARD8	_line_graphics_enable	: 1;
	    CARD8	_background_blink	: 1;
	    CARD8				: 1;
	    CARD8	_pel_panning_compat	: 1;
	    CARD8	_pixel_clock_double	: 1;
	    CARD8	p4_p5_source_select	: 1;
	} _mode_control_s;
	CARD8	_mode_control;
    } _mode_control_u;				    /* AR10 */

#define mode_control		_mode_control_u._mode_control
#define graphics_mode_enable	_mode_control_u._mode_control_s._graphics_mode_enable
#define pixel_clock_double	_mode_control_u._mode_control_s._pixel_clock_double
    
    CARD8   screen_border_color;		    /* AR11 */
    CARD8   enable_color_plane;			    /* AR12 */
    CARD8   horizontal_pixel_pan;		    /* AR13 */
    
    union {
	struct {
	    CARD8   _write_mode		    : 2;
	    CARD8			    : 1;
	    CARD8   _read_mode		    : 1;
	    CARD8   _odd_even_addressing    : 1;
	    CARD8   _shift_register_mode    : 1;
	    CARD8   _color_mode_256	    : 1;
	    CARD8			    : 1;
	} _mode_register_s;
	CARD8	_mode_register;
    } _mode_register_u;				    /* GR5 */
    
#define mode_register	    _mode_register_u._mode_register
#define color_mode_256	    _mode_register_u._mode_register_s._color_mode_256
    
    union {
	struct {
	    CARD8   _dot_clock_8_9	    : 1;
	    CARD8			    : 1;
	    CARD8   _shifter_load_16	    : 1;
	    CARD8   _dot_clock_divide_2	    : 1;
	    CARD8   _shifter_load_32	    : 1;
	    CARD8   _display_off	    : 1;
	    CARD8			    : 2;
	} _clock_mode_s;
	CARD8	_clock_mode;
    } _clock_mode_u;				    /* SR1 */

#define clock_mode	    _clock_mode_u._clock_mode
#define dot_clock_8_9	    _clock_mode_u._clock_mode_s._dot_clock_8_9
#define shifter_load_16	    _clock_mode_u._clock_mode_s._shifter_load_16
#define dot_clock_divide_2  _clock_mode_u._clock_mode_s._dot_clock_divide_2
#define shifter_load_32	    _clock_mode_u._clock_mode_s._shifter_load_32
#define display_off	    _clock_mode_u._clock_mode_s._display_off

    union {
	struct {
	    CARD8   _enhanced_text_mode	    : 1;
	    CARD8   _enhanced_graphics_mode : 1;
	    CARD8   _graphics_mode_32k	    : 1;
	    CARD8   _graphics_mode_64k	    : 1;
	    CARD8   _graphics_mode_true	    : 1;
	    CARD8   _graphics_mode_interlaced: 1;
	    CARD8   _graphics_mode_hw_cursor: 1;
	    CARD8   _graphics_mode_linear   : 1;
	} _graphics_mode_s;
	CARD8	_graphics_mode;
    } _graphics_mode_u;				/* SR6 */

#define graphics_mode		_graphics_mode_u._graphics_mode
#define enhanced_text_mode	_graphics_mode_u._graphics_mode_s._enhanced_text_mode
#define enhanced_graphics_mode  _graphics_mode_u._graphics_mode_s._enhanced_graphics_mode
#define graphics_mode_32k	_graphics_mode_u._graphics_mode_s._graphics_mode_32k
#define graphics_mode_64k	_graphics_mode_u._graphics_mode_s._graphics_mode_64k
#define graphics_mode_true	_graphics_mode_u._graphics_mode_s._graphics_mode_true
#define graphics_mode_interlaced	_graphics_mode_u._graphics_mode_s._graphics_mode_interlaced
#define graphics_mode_hw_cursor	_graphics_mode_u._graphics_mode_s._graphics_mode_hw_cursor
#define graphics_mode_linear	_graphics_mode_u._graphics_mode_s._graphics_mode_linear

    union {
	struct {
	    CARD8   _external_dac_reference : 1;
	    CARD8   _high_speed_dac_0	    : 1;
	    CARD8   _direct_color_24bit	    : 1;
	    CARD8   _multi_line_prefetch    : 1;
	    CARD8   _extended_video_div_2   : 1;
	    CARD8   _ramdac_power_save	    : 1;
	    CARD8			    : 1;
	    CARD8   _merge_video_fifo	    : 1;
	} _misc_control_0_s;
	CARD8	_misc_control_0;
    } _misc_control_0_u;			/* SR7 */

#define misc_control_0	    _misc_control_0_u._misc_control_0
#define external_dac_reference	_misc_control_0_u._misc_control_0_s._external_dac_reference
#define high_speed_dac_0	    _misc_control_0_u._misc_control_0_s._high_speed_dac_0
#define direct_color_24bit	    _misc_control_0_u._misc_control_0_s._direct_color_24bit
#define multi_line_prefetch	    _misc_control_0_u._misc_control_0_s._multi_line_prefetch
#define extended_video_div_2	    _misc_control_0_u._misc_control_0_s._extended_video_div_2
#define ramdac_power_save	    _misc_control_0_u._misc_control_0_s._ramdac_power_save
#define merge_video_fifo	    _misc_control_0_u._misc_control_0_s._merge_video_fifo

    union {
	struct {
	    CARD8   _crt_engine_threshold_high_0_3  : 4;
	    CARD8   _crt_cpu_threshold_low_0_3	    : 4;
	} _crt_cpu_threshold_control_0_s;
	CARD8	_crt_cpu_threshold_control_0;
    } _crt_cpu_threshold_control_0_u;		/* SR8 */
    
#define crt_cpu_threshold_control_0	_crt_cpu_threshold_control_0_u._crt_cpu_threshold_control_0
#define crt_engine_threshold_high_0_3	_crt_cpu_threshold_control_0_u._crt_cpu_threshold_control_0_s._crt_engine_threshold_high_0_3
#define crt_cpu_threshold_low_0_3	_crt_cpu_threshold_control_0_u._crt_cpu_threshold_control_0_s._crt_cpu_threshold_low_0_3

    union {
	struct {
	    CARD8   _crt_cpu_threshold_high_0_3	: 4;
	    CARD8   _ascii_attribute_threshold_0_2 : 3;
	    CARD8   _true_color_32bpp	    : 1;
	} _crt_cpu_threshold_control_1_s;
	CARD8	_crt_cpu_threshold_control_1;
    } _crt_cpu_threshold_control_1_u;		/* SR9 */

#define crt_cpu_threshold_control_1 _crt_cpu_threshold_control_1_u._crt_cpu_threshold_control_1
#define crt_cpu_threshold_high_0_3  _crt_cpu_threshold_control_1_u._crt_cpu_threshold_control_1_s._crt_cpu_threshold_high_0_3
#define ascii_attribute_threshold_0_2	_crt_cpu_threshold_control_1_u._crt_cpu_threshold_control_1_s._ascii_attribute_threshold_0_2
#define true_color_32bpp	    _crt_cpu_threshold_control_1_u._crt_cpu_threshold_control_1_s._true_color_32bpp

    union {
	struct {
	    CARD8   _v_total_10		    : 1;
	    CARD8   _v_display_end_10	    : 1;
	    CARD8   _v_blank_start_10	    : 1;
	    CARD8   _v_retrace_start_10	    : 1;
	    CARD8   _screen_off_8_11	    : 4;
	} _extended_crt_overflow_s;
	CARD8	_extended_crt_overflow;
    } _extended_crt_overflow_u;			    /* SRA */

#define extended_crt_overflow	    _extended_crt_overflow_u._extended_crt_overflow
#define v_total_10		    _extended_crt_overflow_u._extended_crt_overflow_s._v_total_10
#define v_display_end_10	    _extended_crt_overflow_u._extended_crt_overflow_s._v_display_end_10
#define v_blank_start_10	    _extended_crt_overflow_u._extended_crt_overflow_s._v_blank_start_10
#define v_retrace_start_10	    _extended_crt_overflow_u._extended_crt_overflow_s._v_retrace_start_10
#define screen_off_8_11		    _extended_crt_overflow_u._extended_crt_overflow_s._screen_off_8_11

    union {
	struct {
	    CARD8   _cpu_bitblt_enable	    : 1;    /* enable CPU bitblt */
	    CARD8   _packed_16_color_enable : 1;    /* 2 pixels per byte? */
	    CARD8   _io_gating		    : 1;    /* when write buffer not empty */
	    CARD8   _dual_segment_enable    : 1;    /* ? */
	    CARD8   _true_color_modulation  : 1;    /* ? */
	    CARD8   _memory_mapped_mode	    : 2;    /* mmio enable */
	    CARD8   _true_color_order	    : 1;    /* 0: RGB 1: BGR */
	} _misc_control_1_s;
	CARD8   _misc_control_1;	    /* SRB */
    } _misc_control_1_u;
    
#define misc_control_1	_misc_control_1_u._misc_control_1
#define cpu_bitblt_enable   _misc_control_1_u._misc_control_1_s._cpu_bitblt_enable
#define memory_mapped_mode  _misc_control_1_u._misc_control_1_s._memory_mapped_mode
#define true_color_modulation	_misc_control_1_u._misc_control_1_s._true_color_modulation
#define true_color_order    _misc_control_1_u._misc_control_1_s._true_color_order
    
    union {
	struct {
	    CARD8   _sync_reset_enable	    : 1;
	    CARD8   _memory_configuration   : 3;
#define SIS_MEMORY_CONFIG_1M_1BANK  0
#define SIS_MEMORY_CONFIG_2M_2BANK  1
#define SIS_MEMORY_CONFIG_4M_2BANK  2
#define SIS_MEMORY_CONFIG_2M_1BANK  5
#define SIS_MEMORY_CONFIG_4M_1BANK  6
#define SIS_MEMORY_CONFIG_8M_2BANK  7
	    CARD8   _test_mode_enable	    : 1;
	    CARD8   _read_ahead_enable	    : 1;
	    CARD8   _text_mode_16bit_enable : 1;
	    CARD8   _graphics_mode_32bit_enable : 1;
	} _misc_control_2_s;
	CARD8	_misc_control_2;
    } _misc_control_2_u;		    /* SRC */

#define misc_control_2		_misc_control_2_u._misc_control_2
#define sync_reset_enable	_misc_control_2_u._misc_control_2_s._sync_reset_enable
#define memory_configuration	_misc_control_2_u._misc_control_2_s._memory_configuration
#define test_mode_enable	_misc_control_2_u._misc_control_2_s._test_mode_enable
#define read_ahead_enable	_misc_control_2_u._misc_control_2_s._read_ahead_enable
#define text_mode_16bit_enable	_misc_control_2_u._misc_control_2_s._text_mode_16bit_enable
#define graphics_mode_32bit_enable  _misc_control_2_u._misc_control_2_s._graphics_mode_32bit_enable

    union ddc_and_power_control_u {
	struct {
	    CARD8   _ddc_clk_programming    : 1;
	    CARD8   _ddc_data_programming   : 1;
	    CARD8			    : 1;
	    CARD8   _acpi_enable	    : 1;
	    CARD8   _kbd_cursor_activate    : 1;
	    CARD8   _video_memory_activate  : 1;
	    CARD8   _vga_standby	    : 1;
	    CARD8   _vga_suspend	    : 1;
	} _ddc_and_power_control_s;
	CARD8	_ddc_and_power_control;
    } _ddc_and_power_control_u;		    /* SR11 */
    
#define ddc_and_power_control	    _ddc_and_power_control_u._ddc_and_power_control
#define ddc_clk_programming	    _ddc_and_power_control_u._ddc_and_power_control_s._ddc_clk_programming
#define ddc_data_programming	    _ddc_and_power_control_u._ddc_and_power_control_s._ddc_data_programming
#define acpi_enable		    _ddc_and_power_control_u._ddc_and_power_control_s._acpi_enable
#define kbd_cursor_activate	    _ddc_and_power_control_u._ddc_and_power_control_s._kbd_cursor_activate
#define video_memory_activate	    _ddc_and_power_control_u._ddc_and_power_control_s._video_memory_activate
#define vga_standby		    _ddc_and_power_control_u._ddc_and_power_control_s._vga_standby
#define vga_suspend		    _ddc_and_power_control_u._ddc_and_power_control_s._vga_suspend
    
    union {
	struct {
	    CARD8   _h_total_8		    : 1;
	    CARD8   _h_display_end_8	    : 1;
	    CARD8   _h_blank_start_8	    : 1;
	    CARD8   _h_sync_start_8	    : 1;
	    CARD8   _h_blank_end_6	    : 1;
	    CARD8   _h_retrace_skew	    : 3;
	} _extended_horizontal_overflow_s;
	CARD8	_extended_horizontal_overflow;
    } _extended_horizontal_overflow_u;		    /* SR12 */
#define extended_horizontal_overflow	_extended_horizontal_overflow_u._extended_horizontal_overflow
#define h_total_8			_extended_horizontal_overflow_u._extended_horizontal_overflow_s._h_total_8
#define h_display_end_8			_extended_horizontal_overflow_u._extended_horizontal_overflow_s._h_display_end_8
#define h_blank_start_8			_extended_horizontal_overflow_u._extended_horizontal_overflow_s._h_blank_start_8
#define h_sync_start_8		_extended_horizontal_overflow_u._extended_horizontal_overflow_s._h_sync_start_8
#define h_blank_end_6			_extended_horizontal_overflow_u._extended_horizontal_overflow_s._h_blank_end_6
#define h_retrace_skew			_extended_horizontal_overflow_u._extended_horizontal_overflow_s._h_retrace_skew

    union {
	struct {
	    CARD8			    : 6;
	    CARD8   _vclk_post_scale_2	    : 1;
	    CARD8   _mclk_post_scale_2	    : 1;
	} _extended_clock_generator_s;
	CARD8	_extended_clock_generator;
    } _extended_clock_generator_u;		    /* SR13 */

#define extended_clock_generator	 _extended_clock_generator_u._extended_clock_generator
#define vclk_post_scale_2		 _extended_clock_generator_u._extended_clock_generator_s._vclk_post_scale_2
#define mclk_post_scale_2		 _extended_clock_generator_u._extended_clock_generator_s._mclk_post_scale_2

    CARD8   cursor_0_red;			    /* SR14 */
    CARD8   cursor_0_green;			    /* SR15 */
    CARD8   cursor_0_blue;			    /* SR16 */
    
    CARD8   cursor_1_red;			    /* SR17 */
    CARD8   cursor_1_green;			    /* SR18 */
    CARD8   cursor_1_blue;			    /* SR19 */
    
    CARD8   cursor_h_start_0_7;			    /* SR1A */
    union {
	struct {
	    CARD8   _cursor_h_start_8_11    : 4;
	    CARD8			    : 3;
	    CARD8   _cursor_mmio_enable	    : 1;
	} _cusor_h_start_1_s;
	CARD8	_cursor_h_start_1;
    } _cursor_h_start_1_u;			    /* SR1B */

#define cursor_h_start_1		_cursor_h_start_1_u._cursor_h_start_1
#define cursor_h_start_8_11		_cursor_h_start_1_u._cursor_h_start_1_s._cursor_h_start_8_11
    
    CARD8   cursor_h_preset_0_5;		    /* SR1C */
    
    CARD8   cursor_v_start_0_7;			    /* SR1D */
    
    union {
	struct {
	    CARD8   _cursor_v_start_8_10    : 3;
	    CARD8   _cursor_side_pattern    : 1;
	    CARD8   _cursor_pattern	    : 4;
	} _cusor_v_start_1_s;
	CARD8	_cursor_v_start_1;
    } _cursor_v_start_1_u;			    /* SR1E */

#define cursor_v_start_1                _cursor_v_start_1_u._cursor_v_start_1
    
    CARD8   cursor_v_preset_0_5;		    /* SR1F */

    CARD8   linear_base_19_26;			    /* SR20 */

    union {
	struct {
	    CARD8   _linear_base_27_31	    : 5;
	    CARD8   _linear_aperture	    : 3;
#define SIS_LINEAR_APERTURE_512K	0
#define SIS_LINEAR_APERTURE_1M	1
#define SIS_LINEAR_APERTURE_2M	2
#define SIS_LINEAR_APERTURE_4M	3
#define SIS_LINEAR_APERTURE_8M	4
	} _linear_base_1_s;
	CARD8	_linear_base_1;
    } _linear_base_1_u;				    /* SR21 */
    
#define linear_base_1	    _linear_base_1_u._linear_base_1
#define linear_base_27_31   _linear_base_1_u._linear_base_1_s._linear_base_27_31

    union {
	struct {
	    CARD8   _screen_start_addr_20   : 1;
	    CARD8			    : 3;
	    CARD8   _continuous_mem_access  : 1;
	    CARD8			    : 1;
	    CARD8   _power_down_dac	    : 1;
	    CARD8			    : 1;
	} _graphics_engine_0_s;
	CARD8	_graphics_engine_0;
    } _graphics_engine_0_u;			    /* SR26 */

#define graphics_engine_0	_graphics_engine_0_u._graphics_engine_0

    
    union {
	struct {
	    CARD8   _screen_start_addr_16_19: 4;
	    CARD8   _logical_screen_width   : 2;
#define SIS_LOG_SCREEN_WIDTH_1024	0
#define SIS_LOG_SCREEN_WIDTH_2048	1
#define SIS_LOG_SCREEN_WIDTH_4096	2
	    CARD8   _graphics_prog_enable   : 1;
	    CARD8   _turbo_queue_enable	    : 1;
	} _graphics_engine_1_s;
	CARD8	_graphics_engine_1;
    } _graphics_engine_1_u;			    /* SR27 */

#define graphics_engine_1	_graphics_engine_1_u._graphics_engine_1
#define screen_start_addr_16_19	_graphics_engine_1_u._graphics_engine_1_s._screen_start_addr_16_19
#define logical_screen_width	_graphics_engine_1_u._graphics_engine_1_s._logical_screen_width
#define graphics_prog_enable	_graphics_engine_1_u._graphics_engine_1_s._graphics_prog_enable
#define turbo_queue_enable	_graphics_engine_1_u._graphics_engine_1_s._turbo_queue_enable


    union {
	struct {
	    CARD8   _mclk_numerator	    : 7;
	    CARD8   _mclk_divide_by_2	    : 1;
	} _internal_mclk_0_s;
	CARD8	_internal_mclk_0;
    } _internal_mclk_0_u;			    /* SR28 */

#define internal_mclk_0	    _internal_mclk_0_u._internal_mclk_0
#define mclk_numerator	    _internal_mclk_0_u._internal_mclk_0_s._mclk_numerator
#define mclk_divide_by_2    _internal_mclk_0_u._internal_mclk_0_s._mclk_divide_by_2
    
    union {
	struct {
	    CARD8   _mclk_denominator	    : 5;
	    CARD8   _mclk_post_scale	    : 2;
#define SIS_MCLK_POST_SCALE_1	    0
#define SIS_MCLK_POST_SCALE_2	    1
#define SIS_MCLK_POST_SCALE_3	    2
#define SIS_MCLK_POST_SCALE_4	    3
	    CARD8   _mclk_vco_gain	    : 1;
	} _internal_mclk_1_s;
	CARD8	_internal_mclk_1;
    } _internal_mclk_1_u;		    /* SR29 */

#define internal_mclk_1	    _internal_mclk_1_u._internal_mclk_1
#define mclk_denominator    _internal_mclk_1_u._internal_mclk_1_s._mclk_denominator
#define mclk_post_scale	    _internal_mclk_1_u._internal_mclk_1_s._mclk_post_scale
#define mclk_vco_gain	    _internal_mclk_1_u._internal_mclk_1_s._mclk_vco_gain
    
    union {
	struct {
	    CARD8   _vclk_numerator	    : 7;
	    CARD8   _vclk_divide_by_2	    : 1;
	} _internal_vclk_0_s;
	CARD8	_internal_vclk_0;
    } _internal_vclk_0_u;		    /* SR2A */

#define internal_vclk_0	    _internal_vclk_0_u._internal_vclk_0
#define vclk_numerator	    _internal_vclk_0_u._internal_vclk_0_s._vclk_numerator
#define vclk_divide_by_2    _internal_vclk_0_u._internal_vclk_0_s._vclk_divide_by_2
    
    union {
	struct {
	    CARD8   _vclk_denominator	    : 5;
	    CARD8   _vclk_post_scale	    : 2;
#define SIS_VCLK_POST_SCALE_1	    0
#define SIS_VCLK_POST_SCALE_2	    1
#define SIS_VCLK_POST_SCALE_3	    2
#define SIS_VCLK_POST_SCALE_4	    3
	    CARD8   _vclk_vco_gain	    : 1;
	} _internal_vclk_1_s;
	CARD8	_internal_vclk_1;
    } _internal_vclk_1_u;		    /* SR2B */

#define internal_vclk_1	    _internal_vclk_1_u._internal_vclk_1
#define vclk_denominator    _internal_vclk_1_u._internal_vclk_1_s._vclk_denominator
#define vclk_post_scale	    _internal_vclk_1_u._internal_vclk_1_s._vclk_post_scale
#define vclk_vco_gain	    _internal_vclk_1_u._internal_vclk_1_s._vclk_vco_gain
    
    union {
	struct {
	    CARD8   _extended_clock_select  : 2;
#define SIS_CLOCK_SELECT_INTERNAL   0
#define SIS_CLOCK_SELECT_25MHZ	    1
#define SIS_CLOCK_SELECT_28MHZ	    2
	    CARD8   _disable_line_compare   : 1;
	    CARD8   _disable_pci_read_t_o   : 1;
	    CARD8   _cursor_start_addr_18_21: 4;
	} _misc_control_7_s;
	CARD8	_misc_control_7;
    } _misc_control_7_u;			    /* SR38 */

#define misc_control_7		_misc_control_7_u._misc_control_7
#define extended_clock_select	_misc_control_7_u._misc_control_7_s._extended_clock_select
#define disable_line_compare	_misc_control_7_u._misc_control_7_s._disable_line_compare
#define disable_pci_read_t_o	_misc_control_7_u._misc_control_7_s._disable_pci_read_t_o
#define cursor_start_addr_18_21	_misc_control_7_u._misc_control_7_s._cursor_start_addr_18_21

    union {
	struct {
	    CARD8   _high_speed_dclk	    : 1;
	    CARD8   _sgram_block_write	    : 1;
	    CARD8   _cursor_start_addr_22   : 1;
	    CARD8   _dram_texture_read	    : 1;
	    CARD8   _sgram_16mb		    : 1;
	    CARD8   _agp_signal_delay	    : 2;
	    CARD8   _dclk_off		    : 1;
	} _misc_control_11_s;
	CARD8	_misc_control_11;
    } _misc_control_11_u;			    /* SR3E */

#define misc_control_11		_misc_control_11_u._misc_control_11
#define high_speed_dclk		_misc_control_11_u._misc_control_11_s._high_speed_dclk
#define sgram_block_write	_misc_control_11_u._misc_control_11_s.__sgram_block_write
#define cursor_start_addr_22	_misc_control_11_u._misc_control_11_s._cursor_start_addr_22
#define dram_texture_read	_misc_control_11_u._misc_control_11_s._dram_texture_read
#define sgram_16mb		_misc_control_11_u._misc_control_11_s._sgram_16mb
#define agp_signal_delay	_misc_control_11_u._misc_control_11_s._agp_signal_delay
#define dclk_off		_misc_control_11_u._misc_control_11_s._dclk_off
    
    union {
	struct {
	    CARD8			    : 1;
	    CARD8   _flat_panel_low_enable  : 1;
	    CARD8   _crt_cpu_threshold_low_4: 1;
	    CARD8   _crt_engine_threshold_high_4: 1;
	    CARD8   _crt_cpu_threshold_high_4	: 1;
	    CARD8   _crt_threshold_full_control	: 2;
#define SIS_CRT_32_STAGE_THRESHOLD  0
#define SIS_CRT_64_STAGE_THRESHOLD  1
#define SIS_CRT_63_STAGE_THRESHOLD  2
#define SIS_CRT_256_STAGE_THRESHOLD 3
	    CARD8   _high_speed_dac_1	    : 1;
	} _misc_control_12_s;
	CARD8	_misc_control_12;
    } _misc_control_12_u;			    /* SR3F */
#define misc_control_12		_misc_control_12_u._misc_control_12
#define flat_panel_low_enable	_misc_control_12_u._misc_control_12_s._flat_panel_low_enable
#define crt_cpu_threshold_low_4	_misc_control_12_u._misc_control_12_s._crt_cpu_threshold_low_4
#define crt_engine_threshold_high_4 _misc_control_12_u._misc_control_12_s._crt_engine_threshold_high_4
#define crt_cpu_threshold_high_4    _misc_control_12_u._misc_control_12_s._crt_cpu_threshold_high_4
#define crt_threshold_full_control  _misc_control_12_u._misc_control_12_s._crt_threshold_full_control
#define high_speed_dac_1	    _misc_control_12_u._misc_control_12_s._high_speed_dac_1
    
    /* computed values */
    CARD16	    ge_screen_pitch;
    CARD8	    bits_per_pixel;
    CARD8	    depth;
    CARD8	    double_pixel_mode;
    CARD16	    pixel_width;
} SisCrtc;

#define crtc_v_total(crtc)    ((crtc)->v_total_0_7 | \
			       ((crtc)->v_total_8 << 8) | \
			       ((crtc)->v_total_9 << 9) | \
			       ((crtc)->v_total_10 << 10))
    
#define crtc_set_v_total(crtc,v) { \
    ((crtc))->v_total_0_7 = (v); \
    ((crtc))->v_total_8 = (v) >> 8; \
    ((crtc))->v_total_9 = (v) >> 9; \
    ((crtc))->v_total_10 = (v) >> 10; \
}
    
#define crtc_v_display_end(crtc) ((crtc)->v_display_end_0_7 | \
				  ((crtc)->v_display_end_8 << 8) | \
				  ((crtc)->v_display_end_9 << 9) | \
				  ((crtc)->v_display_end_10 << 10))

#define crtc_set_v_display_end(crtc,v) {\
    ((crtc))->v_display_end_0_7 = (v); \
    ((crtc))->v_display_end_8 = (v) >> 8; \
    ((crtc))->v_display_end_9 = (v) >> 9; \
    ((crtc))->v_display_end_10 = (v) >> 10; \
}

#define crtc_v_retrace_start(crtc)  ((crtc)->v_retrace_start_0_7 | \
				     ((crtc)->v_retrace_start_8 << 8) | \
				     ((crtc)->v_retrace_start_9 << 9) | \
				     ((crtc)->v_retrace_start_10 << 10))

#define crtc_set_v_retrace_start(crtc,v) {\
    ((crtc))->v_retrace_start_0_7 = (v); \
    ((crtc))->v_retrace_start_8 = (v) >> 8; \
    ((crtc))->v_retrace_start_9 = (v) >> 9; \
    ((crtc))->v_retrace_start_10 = (v) >> 10; \
}

#define crtc_v_blank_start(crtc)  ((crtc)->v_blank_start_0_7 | \
				   ((crtc)->v_blank_start_8 << 8) | \
				   ((crtc)->v_blank_start_9 << 9) | \
				   ((crtc)->v_blank_start_10 << 10))

#define crtc_set_v_blank_start(crtc,v) {\
    ((crtc))->v_blank_start_0_7 = (v); \
    ((crtc))->v_blank_start_8 = (v) >> 8; \
    ((crtc))->v_blank_start_9 = (v) >> 9; \
    ((crtc))->v_blank_start_10 = (v) >> 10; \
}

#define crtc_h_total(crtc) ((crtc)->h_total_0_7 | \
			    ((crtc)->h_total_8 << 8))

#define crtc_set_h_total(crtc,v) {\
    ((crtc))->h_total_0_7 = (v); \
    ((crtc))->h_total_8 = (v) >> 8; \
}

#define crtc_h_display_end(crtc) ((crtc)->h_display_end_0_7 | \
				  ((crtc)->h_display_end_8 << 8))

#define crtc_set_h_display_end(crtc,v) {\
    ((crtc))->h_display_end_0_7 = (v); \
    ((crtc))->h_display_end_8 = (v) >> 8; \
}

#define crtc_h_blank_start(crtc) ((crtc)->h_blank_start_0_7 | \
				  ((crtc)->h_blank_start_8 << 8))

#define crtc_set_h_blank_start(crtc,v) {\
    ((crtc))->h_blank_start_0_7 = (v); \
    ((crtc))->h_blank_start_8 = (v) >> 8; \
}

#define crtc_h_blank_end(crtc)  ((crtc)->h_blank_end_0_4 | \
				 ((crtc)->h_blank_end_5 << 5))

#define crtc_set_h_blank_end(crtc,v) {\
    ((crtc))->h_blank_end_0_4 = (v); \
    ((crtc))->h_blank_end_5 = (v) >> 5; \
}

#define crtc_h_sync_start(crtc) ((crtc)->h_sync_start_0_7 | \
				 ((crtc)->h_sync_start_8 << 8))

#define crtc_set_h_sync_start(crtc,v) {\
    ((crtc))->h_sync_start_0_7 = (v); \
    ((crtc))->h_sync_start_8 = (v) >> 8; \
}

#define crtc_h_sync_end(crtc) ((crtc)->h_sync_end_0_4)

#define crtc_set_h_sync_end(crtc,v) {\
    ((crtc))->h_sync_end_0_4 = (v); \
}

#define crtc_screen_off(crtc)    ((crtc)->screen_off_0_7 | \
				  ((crtc)->screen_off_8_11 << 8))

#define crtc_set_screen_off(crtc,v) {\
    ((crtc))->screen_off_0_7 = (v); \
    ((crtc))->screen_off_8_11 = (v) >> 8; \
}

#define crtc_ge_screen_width(crtc) ((crtc)->ge_screen_width_0_1 | \
				    ((crtc)->ge_screen_width_2 << 2))

#define crtc_set_ge_screen_width(crtc,v) { \
    (crtc)->ge_screen_width_0_1 = (v); \
    (crtc)->ge_screen_width_2 = (v) >> 2; \
}

#define crtc_h_start_fifo_fetch(crtc) ((crtc)->h_start_fifo_fetch_0_7 | \
				       ((crtc)->h_start_fifo_fetch_8 << 8))

#define crtc_set_h_start_fifo_fetch(crtc,v) {\
    (crtc)->h_start_fifo_fetch_0_7 = (v); \
    (crtc)->h_start_fifo_fetch_8 = (v) >> 8; \
}

#define crtc_start_address(crtc)    ((crtc)->start_address_0_7 | \
				     ((crtc)->start_address_8_15 << 8) | \
				     ((crtc)->start_address_16_19 << 16))

#define crtc_set_start_address(crtc,v) {\
    (crtc)->start_address_0_7 = (v); \
    (crtc)->start_address_8_15 = (v) >> 8; \
    (crtc)->start_address_16_19 = (v) >> 16; \
}

#define crtc_line_compare(crtc)    ((crtc)->line_compare_0_7 | \
				    ((crtc)->line_compare_8 << 8) | \
				    ((crtc)->line_compare_9 << 9) | \
				    ((crtc)->line_compare_10 << 10))

#define crtc_set_line_compare(crtc,v) { \
    ((crtc))->line_compare_0_7 = (v); \
    ((crtc))->line_compare_8 = (v) >> 8; \
    ((crtc))->line_compare_9 = (v) >> 9; \
    ((crtc))->line_compare_10 = (v) >> 10; \
}

#define crtc_set_cursor_start_addr(crtc,v) { \
    (crtc)->cursor_start_addr_18_21 = (v) >> 18; \
    (crtc)->cursor_start_addr_22 = (v) >> 22; \
}

#define _sisOutb(v,r)	    outb(v,r)
#define _sisInb(r)	    inb(r)

#define SIS_DAC_INDEX_READ  0x47
#define SIS_DAC_INDEX_WRITE 0x48
#define SIS_DAC_DATA	    0x49

#define GetCrtc(sisc,i)	    _sisReadIndexRegister ((sisc)->io_base+0x54,i)
#define PutCrtc(sisc,i,v)   _sisWriteIndexRegister ((sisc)->io_base+0x54,i,v)

#define GetSrtc(sisc,i)	    _sisReadIndexRegister ((sisc)->io_base+0x44,i)
#define PutSrtc(sisc,i,v)   _sisWriteIndexRegister ((sisc)->io_base+0x44,i,v)

#define GetArtc(sisc,i)	    _sisReadIndexRegister ((sisc)->io_base+0x40,i)
#define PutArtc(sisc,i,v)   _sisWriteIndexRegister ((sisc)->io_base+0x40,i,v)

#define GetGrtc(sisc,i)	    _sisReadIndexRegister ((sisc)->io_base+0x4e,i)
#define PutGrtc(sisc,i,v)   _sisWriteIndexRegister ((sisc)->io_base+0x4e,i,v)

#define _sisWaitVRetrace(sisc)

#define LockSis(sisc)
#define UnlockSis(sisc)

typedef struct _sisTiming {
    /* label */
    int		horizontal;
    int		vertical;
    int		rate;
    /* horizontal timing */
    int		hfp;	    /* front porch */
    int		hbp;	    /* back porch */
    int		hblank;	    /* blanking */
    /* vertical timing */
    int		vfp;	    /* front porch */
    int		vbp;	    /* back porch */
    int		vblank;	    /* blanking */
} SisTiming;

typedef struct _sisSave {
    CARD8	srb;
    CARD8	sr5;
    SisCrtc	crtc;
} SisSave;

typedef struct _sisCardInfo {
    SisPtr  sis;
    int	    memory;
    CARD8   *frameBuffer;
    CARD8   *registers;
    VOL32   *cpu_bitblt;
    CARD32  io_base;
    SisSave save;
} SisCardInfo;

typedef struct _sisScreenInfo {
    CARD8	*cursor_base;
    CARD32	cursor_off;
    CARD8	*expand;
    CARD32	expand_off;
    int		expand_len;
    SisCursor	cursor;
} SisScreenInfo;

#define getSisCardInfo(kd)	((SisCardInfo *) ((kd)->card->driver))
#define sisCardInfo(kd)		SisCardInfo *sisc = getSisCardInfo(kd)

#define getSisScreenInfo(kd)	((SisScreenInfo *) ((kd)->screen->driver))
#define sisScreenInfo(kd)	SisScreenInfo *siss = getSisScreenInfo(kd)

Bool	sisCardInit (KdCardInfo *);
Bool	sisScreenInit (KdScreenInfo *);
void	sisEnable (ScreenPtr pScreen);
void	sisDisable (ScreenPtr pScreen);
void	sisFini (ScreenPtr pScreen);

Bool	sisCursorInit (ScreenPtr pScreen);
void	sisCursorEnable (ScreenPtr pScreen);
void	sisCursorDisable (ScreenPtr pScreen);
void	sisCursorFini (ScreenPtr pScreen);
void	sisRecolorCursor (ScreenPtr pScreen, int ndef, xColorItem *pdefs);

Bool	sisDrawInit (ScreenPtr pScreen);
void	sisDrawEnable (ScreenPtr pScreen);
void	sisDrawSync (ScreenPtr pScreen);
void	sisDrawDisable (ScreenPtr pScreen);
void	sisDrawFini (ScreenPtr pScreen);

void	sisGetColors (ScreenPtr pScreen, int ndef, xColorItem *pdefs);
void	sisPutColors (ScreenPtr pScreen, int ndef, xColorItem *pdefs);

void	SISInitCard (KdCardAttr *attr);

CARD8	_sisReadIndexRegister (CARD32 base, CARD8 index);
void	_sisWriteIndexRegister (CARD32 base, CARD8 index, CARD8 value);

extern KdCardFuncs  sisFuncs;

/*
 * sisclock.c
 */
void 
sisGetClock (unsigned long clock, SisCrtc *crtc);

void
sisEngThresh (SisCrtc *crtc, unsigned long vclk, int bpp);
    
/*
 * siscurs.c
 */

Bool
sisCursorInit (ScreenPtr pScreen);

void
sisCursorEnable (ScreenPtr pScreen);

void
sisCursorDisable (ScreenPtr pScreen);

void
sisCursorFini (ScreenPtr pScreen);

/* sisdraw.c */
Bool
sisDrawInit (ScreenPtr pScreen);

void
sisDrawEnable (ScreenPtr pScreen);

void
sisDrawDisable (ScreenPtr pScreen);

void
sisDrawFini (ScreenPtr pScreen);

#endif /* _SIS_H_ */