summaryrefslogtreecommitdiffstats
path: root/private/ntos/nthals/halfire/ppc/fpdcc.c
blob: 33b5a175ba00ae2d4c989ae807498b60eb2d6be6 (plain) (blame)
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
/*
 * Copyright (c) 1995  FirePower Systems, Inc.
 * DO NOT DISTRIBUTE without permission
 *
 * $RCSfile: fpdcc.c $
 * $Revision: 1.12 $
 * $Date: 1996/01/11 07:06:05 $
 * $Locker:  $
 *
 * This file contains references to registers in the display controller chip
 *	known as the DCC.  This chip control's vram setup and works in conjunction
 *	with the ram dac which, in this case is a Brooktree Bt485. 
 *
 */

#include "halp.h"
#include "phsystem.h"
#include "fpio.h"
#include "fpDcc.h"
#include "fpbt445.h"

VOID
HalpSetupDCC(
	ULONG Mode,
	ULONG VramWidth
	);
/*++

Routine Description: VOID HalpSetupDCC()

	This routine initializes the display hardware for 640x480 in preparation
	for HalDisplayString(). This means that either we are booting up or
	dealing with the blue screen of death.  We should really change this to
	a higher resolution ASAP. [ged]

Arguments:

	None.

Return Value:

	None.

--*/

VOID
HalpSetupDCC(
	ULONG Mode,
	ULONG VramWidth
	)
{
    LONG modeIndex;
    LONG i;

    //
    // DCC Config A
    //
    UCHAR configA[NUMBER_OF_VRAM_WIDTH_TYPES] = {
        A_1to1_64BitDac | HSYNC_ENABLE | VSYNC_ENABLE | CSYNC_ENABLE,
        A_1to1_64BitDac | HSYNC_ENABLE | VSYNC_ENABLE | CSYNC_ENABLE,
        A_2to1_64BitDac | HSYNC_ENABLE | VSYNC_ENABLE | CSYNC_ENABLE
    };

    // [rdl:01.03.95]
    typedef struct {
        UCHAR reg;
        UCHAR value;
    } DCCTAB;

    // [rdl:01.03.95]
    DCCTAB DCCtab[3 /* 32/64/128 bit vram */][2 /* mode 0 or 15 */][13] = {
        // 32 bit VRAM width
        {
            // [0] Mode  0 - 640X480 8 bit 72Hz
            {
                {HZNTL_COUNT_L,0xcf},
                {HZNTL_COUNT_H,0x00},
                {VERT_COUNT_L,0x07},
                {VERT_COUNT_H,0x02},
                {HZNTL_SYNC_STOP,0x09},
                {HZNTL_BLK_STP_L,0x29},
                {HZNTL_BLK_STP_H,0x00},
                {HZNTL_DTA_STP_L,0xc9},
                {HZNTL_DTA_STP_H,0x00},
                {VERT_SYNC_STOP,0x02},
                {VERT_BLK_STOP,0x1e},
                {VERT_DTA_STP_L,0xfe},
                {VERT_DTA_STP_H,0x01}
            },
            // [1] Mode 15 - 1024X768 8 bit 60Hz
            {
                {HZNTL_COUNT_L,0x4f},
	            {HZNTL_COUNT_H,0x01},
	            {VERT_COUNT_L,0x25},
	            {VERT_COUNT_H,0x03},
	            {HZNTL_SYNC_STOP,0x21},
	            {HZNTL_BLK_STP_L,0x49},
	            {HZNTL_BLK_STP_H,0x00},
	            {HZNTL_DTA_STP_L,0x49},
	            {HZNTL_DTA_STP_H,0x01},
	            {VERT_SYNC_STOP,0x05},
	            {VERT_BLK_STOP,0x22},
	            {VERT_DTA_STP_L,0x22},
	            {VERT_DTA_STP_H,0x03},
            }
        },
        // 64 bit VRAM width
        {
            // [0] Mode  0 - 640X480 8 bit 72Hz
            {
                {HZNTL_COUNT_L,0x67},
                {HZNTL_COUNT_H,0x00},
                {VERT_COUNT_L,0x07},
                {VERT_COUNT_H,0x02},
                {HZNTL_SYNC_STOP,0x04},
                {HZNTL_BLK_STP_L,0x14},
                {HZNTL_BLK_STP_H,0x00},
                {HZNTL_DTA_STP_L,0x64},
                {HZNTL_DTA_STP_H,0x00},
                {VERT_SYNC_STOP,0x02},
                {VERT_BLK_STOP,0x1e},
                {VERT_DTA_STP_L,0xfe},
                {VERT_DTA_STP_H,0x01}
            },
            // [1] Mode 15 - 1024X768 8 bit 60Hz
            {
                {HZNTL_COUNT_L,0xa7},
	            {HZNTL_COUNT_H,0x00},
	            {VERT_COUNT_L,0x25},
	            {VERT_COUNT_H,0x03},
	            {HZNTL_SYNC_STOP,0x10},
	            {HZNTL_BLK_STP_L,0x24},
	            {HZNTL_BLK_STP_H,0x00},
	            {HZNTL_DTA_STP_L,0xa4},
	            {HZNTL_DTA_STP_H,0x00},
	            {VERT_SYNC_STOP,0x05},
	            {VERT_BLK_STOP,0x22},
	            {VERT_DTA_STP_L,0x22},
	            {VERT_DTA_STP_H,0x03},
            }
        },
        // 128 bit VRAM width
        {
            // [0] Mode  0 - 640X480 8 bit 72Hz
            {
                {HZNTL_COUNT_L,0x67},
                {HZNTL_COUNT_H,0x00},
                {VERT_COUNT_L,0x07},
                {VERT_COUNT_H,0x02},
                {HZNTL_SYNC_STOP,0x04},
                {HZNTL_BLK_STP_L,0x14},
                {HZNTL_BLK_STP_H,0x00},
                {HZNTL_DTA_STP_L,0x64},
                {HZNTL_DTA_STP_H,0x00},
                {VERT_SYNC_STOP,0x02},
                {VERT_BLK_STOP,0x1e},
                {VERT_DTA_STP_L,0xfe},
                {VERT_DTA_STP_H,0x01}
            },
            // [1] Mode 15 - 1024X768 8 bit 60Hz
            {
                {HZNTL_COUNT_L,0xa7},
	            {HZNTL_COUNT_H,0x00},
	            {VERT_COUNT_L,0x25},
	            {VERT_COUNT_H,0x03},
	            {HZNTL_SYNC_STOP,0x10},
	            {HZNTL_BLK_STP_L,0x24},
	            {HZNTL_BLK_STP_H,0x00},
	            {HZNTL_DTA_STP_L,0xa4},
	            {HZNTL_DTA_STP_H,0x00},
	            {VERT_SYNC_STOP,0x05},
	            {VERT_BLK_STOP,0x22},
	            {VERT_DTA_STP_L,0x22},
	            {VERT_DTA_STP_H,0x03},
            }
        }
    };


	//
	// Disable all counters and state machines before we go messing around.
	//
	rDccIndex = dccConfigB;
	FireSyncRegister();
	rDccData = DCC_HALT_CLK;
	FireSyncRegister();

	HalpSetupBt445(Mode, VramWidth);

	//
	// Setup the DCC
	//
	rDccIndex = dccIntReg;
	FireSyncRegister();
	rDccData = 0x00;		// Clear the interrupt bit ( bit 0 )
	FireSyncRegister();

	rDccIndex = dccTimingA;
	FireSyncRegister();
	rDccData = 0x07;		// delay syncs by 7 DispClk cycles
	FireSyncRegister();

	rDccIndex = dccConfigA;
	FireSyncRegister();
	rDccData = configA[VramWidth];
	FireSyncRegister();

#define DCC_STORE(reg,val) { \
    WRITE_REGISTER_UCHAR((PUCHAR)HalpIoControlBase + DCC_INDEX, reg); \
    WRITE_REGISTER_UCHAR((PUCHAR)HalpIoControlBase + DCC_DATA, val); \
}

    // go table driven [rdl:01.03.95]
    modeIndex = (Mode) ? 1 : 0;         // if not mode 0, then make it mode 15.
    for (i = 0; i < sizeof(DCCtab[0][0])/sizeof(DCCTAB); i++) {
        DCCTAB tab = DCCtab[VramWidth][modeIndex][i];
        DCC_STORE(tab.reg, tab.value);
    }

	rDccIndex = dccConfigB; 		// Turn on counters, *DO LAST*
	FireSyncRegister();
	rDccData = 0x00;
	FireSyncRegister();

	return;
} // HalpSetupDCC