This source file includes following definitions.
- InitialiseRamdac
- DisableRamdacOutput
- EnableRamdacOutput
1
2
3
4
5
6
7
8
9
10
11 #include <linux/kernel.h>
12 #include <linux/errno.h>
13 #include <linux/types.h>
14 #include <video/kyro.h>
15
16 #include "STG4000Reg.h"
17 #include "STG4000Interface.h"
18
19 static u32 STG_PIXEL_BUS_WIDTH = 128;
20 static u32 REF_CLOCK = 14318;
21
22 int InitialiseRamdac(volatile STG4000REG __iomem * pSTGReg,
23 u32 displayDepth,
24 u32 displayWidth,
25 u32 displayHeight,
26 s32 HSyncPolarity,
27 s32 VSyncPolarity, u32 * pixelClock)
28 {
29 u32 tmp = 0;
30 u32 F = 0, R = 0, P = 0;
31 u32 stride = 0;
32 u32 ulPdiv = 0;
33 u32 physicalPixelDepth = 0;
34
35 tmp = STG_READ_REG(SoftwareReset);
36
37 if (tmp & 0x1) {
38 CLEAR_BIT(1);
39 STG_WRITE_REG(SoftwareReset, tmp);
40 }
41
42
43 tmp = STG_READ_REG(DACPixelFormat);
44 CLEAR_BITS_FRM_TO(0, 2);
45
46
47 CLEAR_BITS_FRM_TO(8, 9);
48
49 switch (displayDepth) {
50 case 16:
51 {
52 physicalPixelDepth = 16;
53 tmp |= _16BPP;
54 break;
55 }
56 case 32:
57 {
58
59 physicalPixelDepth = 32;
60 tmp |= _32BPP;
61 break;
62 }
63 default:
64 return -EINVAL;
65 }
66
67 STG_WRITE_REG(DACPixelFormat, tmp);
68
69
70 ulPdiv = STG_PIXEL_BUS_WIDTH / physicalPixelDepth;
71
72
73 stride = displayWidth;
74
75
76 tmp = STG_READ_REG(DACPrimSize);
77 CLEAR_BITS_FRM_TO(0, 10);
78 CLEAR_BITS_FRM_TO(12, 31);
79 tmp |=
80 ((((displayHeight - 1) << 12) | (((displayWidth / ulPdiv) -
81 1) << 23))
82 | (stride / ulPdiv));
83 STG_WRITE_REG(DACPrimSize, tmp);
84
85
86
87 *pixelClock = ProgramClock(REF_CLOCK, *pixelClock, &F, &R, &P);
88
89
90 tmp = STG_READ_REG(DACPLLMode);
91 CLEAR_BITS_FRM_TO(0, 15);
92
93 tmp |= ((P) | ((F - 2) << 2) | ((R - 2) << 11));
94 STG_WRITE_REG(DACPLLMode, tmp);
95
96
97 tmp = STG_READ_REG(DACPrimAddress);
98 CLEAR_BITS_FRM_TO(0, 20);
99 CLEAR_BITS_FRM_TO(20, 31);
100 STG_WRITE_REG(DACPrimAddress, tmp);
101
102
103 tmp = STG_READ_REG(DACCursorCtrl);
104 tmp &= ~SET_BIT(31);
105 STG_WRITE_REG(DACCursorCtrl, tmp);
106
107 tmp = STG_READ_REG(DACCursorAddr);
108 CLEAR_BITS_FRM_TO(0, 20);
109 STG_WRITE_REG(DACCursorAddr, tmp);
110
111
112 tmp = STG_READ_REG(DACVidWinStart);
113 CLEAR_BITS_FRM_TO(0, 10);
114 CLEAR_BITS_FRM_TO(16, 26);
115 STG_WRITE_REG(DACVidWinStart, tmp);
116
117 tmp = STG_READ_REG(DACVidWinEnd);
118 CLEAR_BITS_FRM_TO(0, 10);
119 CLEAR_BITS_FRM_TO(16, 26);
120 STG_WRITE_REG(DACVidWinEnd, tmp);
121
122
123 tmp = STG_READ_REG(DACBorderColor);
124 CLEAR_BITS_FRM_TO(0, 23);
125 STG_WRITE_REG(DACBorderColor, tmp);
126
127
128 STG_WRITE_REG(DACBurstCtrl, 0x0404);
129
130
131 tmp = STG_READ_REG(DACCrcTrigger);
132 CLEAR_BIT(0);
133 STG_WRITE_REG(DACCrcTrigger, tmp);
134
135
136 tmp = STG_READ_REG(DigVidPortCtrl);
137 CLEAR_BIT(8);
138 CLEAR_BITS_FRM_TO(16, 27);
139 CLEAR_BITS_FRM_TO(1, 3);
140 CLEAR_BITS_FRM_TO(10, 11);
141 STG_WRITE_REG(DigVidPortCtrl, tmp);
142
143 return 0;
144 }
145
146
147 void DisableRamdacOutput(volatile STG4000REG __iomem * pSTGReg)
148 {
149 u32 tmp;
150
151
152 tmp = (STG_READ_REG(DACStreamCtrl)) & ~SET_BIT(0);
153 STG_WRITE_REG(DACStreamCtrl, tmp);
154 }
155
156 void EnableRamdacOutput(volatile STG4000REG __iomem * pSTGReg)
157 {
158 u32 tmp;
159
160
161 tmp = (STG_READ_REG(DACStreamCtrl)) | SET_BIT(0);
162 STG_WRITE_REG(DACStreamCtrl, tmp);
163 }