diff options
author | Linus Torvalds <torvalds@ppc970.osdl.org> | 2005-04-16 18:20:36 -0400 |
---|---|---|
committer | Linus Torvalds <torvalds@ppc970.osdl.org> | 2005-04-16 18:20:36 -0400 |
commit | 1da177e4c3f41524e886b7f1b8a0c1fc7321cac2 (patch) | |
tree | 0bba044c4ce775e45a88a51686b5d9f90697ea9d /drivers/char/drm/mga_warp.c |
Linux-2.6.12-rc2v2.6.12-rc2
Initial git repository build. I'm not bothering with the full history,
even though we have it. We can create a separate "historical" git
archive of that later if we want to, and in the meantime it's about
3.2GB when imported into git - space that would just make the early
git days unnecessarily complicated, when we don't have a lot of good
infrastructure for it.
Let it rip!
Diffstat (limited to 'drivers/char/drm/mga_warp.c')
-rw-r--r-- | drivers/char/drm/mga_warp.c | 210 |
1 files changed, 210 insertions, 0 deletions
diff --git a/drivers/char/drm/mga_warp.c b/drivers/char/drm/mga_warp.c new file mode 100644 index 000000000000..0a3a0cc700dc --- /dev/null +++ b/drivers/char/drm/mga_warp.c | |||
@@ -0,0 +1,210 @@ | |||
1 | /* mga_warp.c -- Matrox G200/G400 WARP engine management -*- linux-c -*- | ||
2 | * Created: Thu Jan 11 21:29:32 2001 by gareth@valinux.com | ||
3 | * | ||
4 | * Copyright 2000 VA Linux Systems, Inc., Sunnyvale, California. | ||
5 | * All Rights Reserved. | ||
6 | * | ||
7 | * Permission is hereby granted, free of charge, to any person obtaining a | ||
8 | * copy of this software and associated documentation files (the "Software"), | ||
9 | * to deal in the Software without restriction, including without limitation | ||
10 | * the rights to use, copy, modify, merge, publish, distribute, sublicense, | ||
11 | * and/or sell copies of the Software, and to permit persons to whom the | ||
12 | * Software is furnished to do so, subject to the following conditions: | ||
13 | * | ||
14 | * The above copyright notice and this permission notice (including the next | ||
15 | * paragraph) shall be included in all copies or substantial portions of the | ||
16 | * Software. | ||
17 | * | ||
18 | * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR | ||
19 | * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, | ||
20 | * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL | ||
21 | * VA LINUX SYSTEMS AND/OR ITS SUPPLIERS BE LIABLE FOR ANY CLAIM, DAMAGES OR | ||
22 | * OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, | ||
23 | * ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR | ||
24 | * OTHER DEALINGS IN THE SOFTWARE. | ||
25 | * | ||
26 | * Authors: | ||
27 | * Gareth Hughes <gareth@valinux.com> | ||
28 | */ | ||
29 | |||
30 | #include "drmP.h" | ||
31 | #include "drm.h" | ||
32 | #include "mga_drm.h" | ||
33 | #include "mga_drv.h" | ||
34 | #include "mga_ucode.h" | ||
35 | |||
36 | |||
37 | #define MGA_WARP_CODE_ALIGN 256 /* in bytes */ | ||
38 | |||
39 | #define WARP_UCODE_SIZE( which ) \ | ||
40 | ((sizeof(which) / MGA_WARP_CODE_ALIGN + 1) * MGA_WARP_CODE_ALIGN) | ||
41 | |||
42 | #define WARP_UCODE_INSTALL( which, where ) \ | ||
43 | do { \ | ||
44 | DRM_DEBUG( " pcbase = 0x%08lx vcbase = %p\n", pcbase, vcbase );\ | ||
45 | dev_priv->warp_pipe_phys[where] = pcbase; \ | ||
46 | memcpy( vcbase, which, sizeof(which) ); \ | ||
47 | pcbase += WARP_UCODE_SIZE( which ); \ | ||
48 | vcbase += WARP_UCODE_SIZE( which ); \ | ||
49 | } while (0) | ||
50 | |||
51 | |||
52 | static unsigned int mga_warp_g400_microcode_size( drm_mga_private_t *dev_priv ) | ||
53 | { | ||
54 | unsigned int size; | ||
55 | |||
56 | size = ( WARP_UCODE_SIZE( warp_g400_tgz ) + | ||
57 | WARP_UCODE_SIZE( warp_g400_tgza ) + | ||
58 | WARP_UCODE_SIZE( warp_g400_tgzaf ) + | ||
59 | WARP_UCODE_SIZE( warp_g400_tgzf ) + | ||
60 | WARP_UCODE_SIZE( warp_g400_tgzs ) + | ||
61 | WARP_UCODE_SIZE( warp_g400_tgzsa ) + | ||
62 | WARP_UCODE_SIZE( warp_g400_tgzsaf ) + | ||
63 | WARP_UCODE_SIZE( warp_g400_tgzsf ) + | ||
64 | WARP_UCODE_SIZE( warp_g400_t2gz ) + | ||
65 | WARP_UCODE_SIZE( warp_g400_t2gza ) + | ||
66 | WARP_UCODE_SIZE( warp_g400_t2gzaf ) + | ||
67 | WARP_UCODE_SIZE( warp_g400_t2gzf ) + | ||
68 | WARP_UCODE_SIZE( warp_g400_t2gzs ) + | ||
69 | WARP_UCODE_SIZE( warp_g400_t2gzsa ) + | ||
70 | WARP_UCODE_SIZE( warp_g400_t2gzsaf ) + | ||
71 | WARP_UCODE_SIZE( warp_g400_t2gzsf ) ); | ||
72 | |||
73 | size = PAGE_ALIGN( size ); | ||
74 | |||
75 | DRM_DEBUG( "G400 ucode size = %d bytes\n", size ); | ||
76 | return size; | ||
77 | } | ||
78 | |||
79 | static unsigned int mga_warp_g200_microcode_size( drm_mga_private_t *dev_priv ) | ||
80 | { | ||
81 | unsigned int size; | ||
82 | |||
83 | size = ( WARP_UCODE_SIZE( warp_g200_tgz ) + | ||
84 | WARP_UCODE_SIZE( warp_g200_tgza ) + | ||
85 | WARP_UCODE_SIZE( warp_g200_tgzaf ) + | ||
86 | WARP_UCODE_SIZE( warp_g200_tgzf ) + | ||
87 | WARP_UCODE_SIZE( warp_g200_tgzs ) + | ||
88 | WARP_UCODE_SIZE( warp_g200_tgzsa ) + | ||
89 | WARP_UCODE_SIZE( warp_g200_tgzsaf ) + | ||
90 | WARP_UCODE_SIZE( warp_g200_tgzsf ) ); | ||
91 | |||
92 | size = PAGE_ALIGN( size ); | ||
93 | |||
94 | DRM_DEBUG( "G200 ucode size = %d bytes\n", size ); | ||
95 | return size; | ||
96 | } | ||
97 | |||
98 | static int mga_warp_install_g400_microcode( drm_mga_private_t *dev_priv ) | ||
99 | { | ||
100 | unsigned char *vcbase = dev_priv->warp->handle; | ||
101 | unsigned long pcbase = dev_priv->warp->offset; | ||
102 | unsigned int size; | ||
103 | |||
104 | size = mga_warp_g400_microcode_size( dev_priv ); | ||
105 | if ( size > dev_priv->warp->size ) { | ||
106 | DRM_ERROR( "microcode too large! (%u > %lu)\n", | ||
107 | size, dev_priv->warp->size ); | ||
108 | return DRM_ERR(ENOMEM); | ||
109 | } | ||
110 | |||
111 | memset( dev_priv->warp_pipe_phys, 0, | ||
112 | sizeof(dev_priv->warp_pipe_phys) ); | ||
113 | |||
114 | WARP_UCODE_INSTALL( warp_g400_tgz, MGA_WARP_TGZ ); | ||
115 | WARP_UCODE_INSTALL( warp_g400_tgzf, MGA_WARP_TGZF ); | ||
116 | WARP_UCODE_INSTALL( warp_g400_tgza, MGA_WARP_TGZA ); | ||
117 | WARP_UCODE_INSTALL( warp_g400_tgzaf, MGA_WARP_TGZAF ); | ||
118 | WARP_UCODE_INSTALL( warp_g400_tgzs, MGA_WARP_TGZS ); | ||
119 | WARP_UCODE_INSTALL( warp_g400_tgzsf, MGA_WARP_TGZSF ); | ||
120 | WARP_UCODE_INSTALL( warp_g400_tgzsa, MGA_WARP_TGZSA ); | ||
121 | WARP_UCODE_INSTALL( warp_g400_tgzsaf, MGA_WARP_TGZSAF ); | ||
122 | |||
123 | WARP_UCODE_INSTALL( warp_g400_t2gz, MGA_WARP_T2GZ ); | ||
124 | WARP_UCODE_INSTALL( warp_g400_t2gzf, MGA_WARP_T2GZF ); | ||
125 | WARP_UCODE_INSTALL( warp_g400_t2gza, MGA_WARP_T2GZA ); | ||
126 | WARP_UCODE_INSTALL( warp_g400_t2gzaf, MGA_WARP_T2GZAF ); | ||
127 | WARP_UCODE_INSTALL( warp_g400_t2gzs, MGA_WARP_T2GZS ); | ||
128 | WARP_UCODE_INSTALL( warp_g400_t2gzsf, MGA_WARP_T2GZSF ); | ||
129 | WARP_UCODE_INSTALL( warp_g400_t2gzsa, MGA_WARP_T2GZSA ); | ||
130 | WARP_UCODE_INSTALL( warp_g400_t2gzsaf, MGA_WARP_T2GZSAF ); | ||
131 | |||
132 | return 0; | ||
133 | } | ||
134 | |||
135 | static int mga_warp_install_g200_microcode( drm_mga_private_t *dev_priv ) | ||
136 | { | ||
137 | unsigned char *vcbase = dev_priv->warp->handle; | ||
138 | unsigned long pcbase = dev_priv->warp->offset; | ||
139 | unsigned int size; | ||
140 | |||
141 | size = mga_warp_g200_microcode_size( dev_priv ); | ||
142 | if ( size > dev_priv->warp->size ) { | ||
143 | DRM_ERROR( "microcode too large! (%u > %lu)\n", | ||
144 | size, dev_priv->warp->size ); | ||
145 | return DRM_ERR(ENOMEM); | ||
146 | } | ||
147 | |||
148 | memset( dev_priv->warp_pipe_phys, 0, | ||
149 | sizeof(dev_priv->warp_pipe_phys) ); | ||
150 | |||
151 | WARP_UCODE_INSTALL( warp_g200_tgz, MGA_WARP_TGZ ); | ||
152 | WARP_UCODE_INSTALL( warp_g200_tgzf, MGA_WARP_TGZF ); | ||
153 | WARP_UCODE_INSTALL( warp_g200_tgza, MGA_WARP_TGZA ); | ||
154 | WARP_UCODE_INSTALL( warp_g200_tgzaf, MGA_WARP_TGZAF ); | ||
155 | WARP_UCODE_INSTALL( warp_g200_tgzs, MGA_WARP_TGZS ); | ||
156 | WARP_UCODE_INSTALL( warp_g200_tgzsf, MGA_WARP_TGZSF ); | ||
157 | WARP_UCODE_INSTALL( warp_g200_tgzsa, MGA_WARP_TGZSA ); | ||
158 | WARP_UCODE_INSTALL( warp_g200_tgzsaf, MGA_WARP_TGZSAF ); | ||
159 | |||
160 | return 0; | ||
161 | } | ||
162 | |||
163 | int mga_warp_install_microcode( drm_mga_private_t *dev_priv ) | ||
164 | { | ||
165 | switch ( dev_priv->chipset ) { | ||
166 | case MGA_CARD_TYPE_G400: | ||
167 | return mga_warp_install_g400_microcode( dev_priv ); | ||
168 | case MGA_CARD_TYPE_G200: | ||
169 | return mga_warp_install_g200_microcode( dev_priv ); | ||
170 | default: | ||
171 | return DRM_ERR(EINVAL); | ||
172 | } | ||
173 | } | ||
174 | |||
175 | #define WMISC_EXPECTED (MGA_WUCODECACHE_ENABLE | MGA_WMASTER_ENABLE) | ||
176 | |||
177 | int mga_warp_init( drm_mga_private_t *dev_priv ) | ||
178 | { | ||
179 | u32 wmisc; | ||
180 | |||
181 | /* FIXME: Get rid of these damned magic numbers... | ||
182 | */ | ||
183 | switch ( dev_priv->chipset ) { | ||
184 | case MGA_CARD_TYPE_G400: | ||
185 | MGA_WRITE( MGA_WIADDR2, MGA_WMODE_SUSPEND ); | ||
186 | MGA_WRITE( MGA_WGETMSB, 0x00000E00 ); | ||
187 | MGA_WRITE( MGA_WVRTXSZ, 0x00001807 ); | ||
188 | MGA_WRITE( MGA_WACCEPTSEQ, 0x18000000 ); | ||
189 | break; | ||
190 | case MGA_CARD_TYPE_G200: | ||
191 | MGA_WRITE( MGA_WIADDR, MGA_WMODE_SUSPEND ); | ||
192 | MGA_WRITE( MGA_WGETMSB, 0x1606 ); | ||
193 | MGA_WRITE( MGA_WVRTXSZ, 7 ); | ||
194 | break; | ||
195 | default: | ||
196 | return DRM_ERR(EINVAL); | ||
197 | } | ||
198 | |||
199 | MGA_WRITE( MGA_WMISC, (MGA_WUCODECACHE_ENABLE | | ||
200 | MGA_WMASTER_ENABLE | | ||
201 | MGA_WCACHEFLUSH_ENABLE) ); | ||
202 | wmisc = MGA_READ( MGA_WMISC ); | ||
203 | if ( wmisc != WMISC_EXPECTED ) { | ||
204 | DRM_ERROR( "WARP engine config failed! 0x%x != 0x%x\n", | ||
205 | wmisc, WMISC_EXPECTED ); | ||
206 | return DRM_ERR(EINVAL); | ||
207 | } | ||
208 | |||
209 | return 0; | ||
210 | } | ||