]>
git.proxmox.com Git - mirror_ubuntu-bionic-kernel.git/blob - drivers/video/kyro/STG4000Ramdac.c
2 * linux/drivers/video/kyro/STG4000Ramdac.c
4 * Copyright (C) 2002 STMicroelectronics
6 * This file is subject to the terms and conditions of the GNU General Public
7 * License. See the file COPYING in the main directory of this archive
11 #include <linux/kernel.h>
12 #include <linux/errno.h>
13 #include <linux/types.h>
14 #include <video/kyro.h>
16 #include "STG4000Reg.h"
17 #include "STG4000Interface.h"
19 static u32 STG_PIXEL_BUS_WIDTH
= 128; /* 128 bit bus width */
20 static u32 REF_CLOCK
= 14318;
22 int InitialiseRamdac(volatile STG4000REG __iomem
* pSTGReg
,
27 s32 VSyncPolarity
, u32
* pixelClock
)
30 u32 F
= 0, R
= 0, P
= 0;
33 u32 physicalPixelDepth
= 0;
34 /* Make sure DAC is in Reset */
35 tmp
= STG_READ_REG(SoftwareReset
);
39 STG_WRITE_REG(SoftwareReset
, tmp
);
42 /* Set Pixel Format */
43 tmp
= STG_READ_REG(DACPixelFormat
);
44 CLEAR_BITS_FRM_TO(0, 2);
46 /* Set LUT not used from 16bpp to 32 bpp ??? */
47 CLEAR_BITS_FRM_TO(8, 9);
49 switch (displayDepth
) {
52 physicalPixelDepth
= 16;
58 /* Set for 32 bits per pixel */
59 physicalPixelDepth
= 32;
67 STG_WRITE_REG(DACPixelFormat
, tmp
);
69 /* Workout Bus transfer bandwidth according to pixel format */
70 ulPdiv
= STG_PIXEL_BUS_WIDTH
/ physicalPixelDepth
;
72 /* Get Screen Stride in pixels */
73 stride
= displayWidth
;
75 /* Set Primary size info */
76 tmp
= STG_READ_REG(DACPrimSize
);
77 CLEAR_BITS_FRM_TO(0, 10);
78 CLEAR_BITS_FRM_TO(12, 31);
80 ((((displayHeight
- 1) << 12) | (((displayWidth
/ ulPdiv
) -
83 STG_WRITE_REG(DACPrimSize
, tmp
);
87 *pixelClock
= ProgramClock(REF_CLOCK
, *pixelClock
, &F
, &R
, &P
);
89 /* Set DAC PLL Mode */
90 tmp
= STG_READ_REG(DACPLLMode
);
91 CLEAR_BITS_FRM_TO(0, 15);
92 /* tmp |= ((P-1) | ((F-2) << 2) | ((R-2) << 11)); */
93 tmp
|= ((P
) | ((F
- 2) << 2) | ((R
- 2) << 11));
94 STG_WRITE_REG(DACPLLMode
, tmp
);
96 /* Set Prim Address */
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
);
102 /* Set Cursor details with HW Cursor disabled */
103 tmp
= STG_READ_REG(DACCursorCtrl
);
105 STG_WRITE_REG(DACCursorCtrl
, tmp
);
107 tmp
= STG_READ_REG(DACCursorAddr
);
108 CLEAR_BITS_FRM_TO(0, 20);
109 STG_WRITE_REG(DACCursorAddr
, tmp
);
111 /* Set Video Window */
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
);
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
);
122 /* Set DAC Border Color to default */
123 tmp
= STG_READ_REG(DACBorderColor
);
124 CLEAR_BITS_FRM_TO(0, 23);
125 STG_WRITE_REG(DACBorderColor
, tmp
);
127 /* Set Graphics and Overlay Burst Control */
128 STG_WRITE_REG(DACBurstCtrl
, 0x0404);
130 /* Set CRC Trigger to default */
131 tmp
= STG_READ_REG(DACCrcTrigger
);
133 STG_WRITE_REG(DACCrcTrigger
, tmp
);
135 /* Set Video Port Control to default */
136 tmp
= STG_READ_REG(DigVidPortCtrl
);
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
);
146 /* Ramdac control, turning output to the screen on and off */
147 void DisableRamdacOutput(volatile STG4000REG __iomem
* pSTGReg
)
151 /* Disable DAC for Graphics Stream Control */
152 tmp
= (STG_READ_REG(DACStreamCtrl
)) & ~SET_BIT(0);
153 STG_WRITE_REG(DACStreamCtrl
, tmp
);
156 void EnableRamdacOutput(volatile STG4000REG __iomem
* pSTGReg
)
160 /* Enable DAC for Graphics Stream Control */
161 tmp
= (STG_READ_REG(DACStreamCtrl
)) | SET_BIT(0);
162 STG_WRITE_REG(DACStreamCtrl
, tmp
);