diff options
author | Dave Airlie <airlied@starflyer.(none)> | 2005-09-25 00:28:13 -0400 |
---|---|---|
committer | Dave Airlie <airlied@linux.ie> | 2005-09-25 00:28:13 -0400 |
commit | b5e89ed53ed8d24f83ba1941c07382af00ed238e (patch) | |
tree | 747bae7a565f88a2e1d5974776eeb054a932c505 /drivers/char/drm/r128_cce.c | |
parent | 99a2657a29e2d623c3568cd86b27cac13fb63140 (diff) |
drm: lindent the drm directory.
I've been threatening this for a while, so no point hanging around.
This lindents the DRM code which was always really bad in tabbing department.
I've also fixed some misnamed files in comments and removed some trailing
whitespace.
Signed-off-by: Dave Airlie <airlied@linux.ie>
Diffstat (limited to 'drivers/char/drm/r128_cce.c')
-rw-r--r-- | drivers/char/drm/r128_cce.c | 590 |
1 files changed, 295 insertions, 295 deletions
diff --git a/drivers/char/drm/r128_cce.c b/drivers/char/drm/r128_cce.c index ac3ea2bc9b28..7452753d4d01 100644 --- a/drivers/char/drm/r128_cce.c +++ b/drivers/char/drm/r128_cce.c | |||
@@ -80,7 +80,7 @@ static u32 r128_cce_microcode[] = { | |||
80 | 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0 | 80 | 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0 |
81 | }; | 81 | }; |
82 | 82 | ||
83 | static int R128_READ_PLL(drm_device_t *dev, int addr) | 83 | static int R128_READ_PLL(drm_device_t * dev, int addr) |
84 | { | 84 | { |
85 | drm_r128_private_t *dev_priv = dev->dev_private; | 85 | drm_r128_private_t *dev_priv = dev->dev_private; |
86 | 86 | ||
@@ -89,106 +89,105 @@ static int R128_READ_PLL(drm_device_t *dev, int addr) | |||
89 | } | 89 | } |
90 | 90 | ||
91 | #if R128_FIFO_DEBUG | 91 | #if R128_FIFO_DEBUG |
92 | static void r128_status( drm_r128_private_t *dev_priv ) | 92 | static void r128_status(drm_r128_private_t * dev_priv) |
93 | { | 93 | { |
94 | printk( "GUI_STAT = 0x%08x\n", | 94 | printk("GUI_STAT = 0x%08x\n", |
95 | (unsigned int)R128_READ( R128_GUI_STAT ) ); | 95 | (unsigned int)R128_READ(R128_GUI_STAT)); |
96 | printk( "PM4_STAT = 0x%08x\n", | 96 | printk("PM4_STAT = 0x%08x\n", |
97 | (unsigned int)R128_READ( R128_PM4_STAT ) ); | 97 | (unsigned int)R128_READ(R128_PM4_STAT)); |
98 | printk( "PM4_BUFFER_DL_WPTR = 0x%08x\n", | 98 | printk("PM4_BUFFER_DL_WPTR = 0x%08x\n", |
99 | (unsigned int)R128_READ( R128_PM4_BUFFER_DL_WPTR ) ); | 99 | (unsigned int)R128_READ(R128_PM4_BUFFER_DL_WPTR)); |
100 | printk( "PM4_BUFFER_DL_RPTR = 0x%08x\n", | 100 | printk("PM4_BUFFER_DL_RPTR = 0x%08x\n", |
101 | (unsigned int)R128_READ( R128_PM4_BUFFER_DL_RPTR ) ); | 101 | (unsigned int)R128_READ(R128_PM4_BUFFER_DL_RPTR)); |
102 | printk( "PM4_MICRO_CNTL = 0x%08x\n", | 102 | printk("PM4_MICRO_CNTL = 0x%08x\n", |
103 | (unsigned int)R128_READ( R128_PM4_MICRO_CNTL ) ); | 103 | (unsigned int)R128_READ(R128_PM4_MICRO_CNTL)); |
104 | printk( "PM4_BUFFER_CNTL = 0x%08x\n", | 104 | printk("PM4_BUFFER_CNTL = 0x%08x\n", |
105 | (unsigned int)R128_READ( R128_PM4_BUFFER_CNTL ) ); | 105 | (unsigned int)R128_READ(R128_PM4_BUFFER_CNTL)); |
106 | } | 106 | } |
107 | #endif | 107 | #endif |
108 | 108 | ||
109 | |||
110 | /* ================================================================ | 109 | /* ================================================================ |
111 | * Engine, FIFO control | 110 | * Engine, FIFO control |
112 | */ | 111 | */ |
113 | 112 | ||
114 | static int r128_do_pixcache_flush( drm_r128_private_t *dev_priv ) | 113 | static int r128_do_pixcache_flush(drm_r128_private_t * dev_priv) |
115 | { | 114 | { |
116 | u32 tmp; | 115 | u32 tmp; |
117 | int i; | 116 | int i; |
118 | 117 | ||
119 | tmp = R128_READ( R128_PC_NGUI_CTLSTAT ) | R128_PC_FLUSH_ALL; | 118 | tmp = R128_READ(R128_PC_NGUI_CTLSTAT) | R128_PC_FLUSH_ALL; |
120 | R128_WRITE( R128_PC_NGUI_CTLSTAT, tmp ); | 119 | R128_WRITE(R128_PC_NGUI_CTLSTAT, tmp); |
121 | 120 | ||
122 | for ( i = 0 ; i < dev_priv->usec_timeout ; i++ ) { | 121 | for (i = 0; i < dev_priv->usec_timeout; i++) { |
123 | if ( !(R128_READ( R128_PC_NGUI_CTLSTAT ) & R128_PC_BUSY) ) { | 122 | if (!(R128_READ(R128_PC_NGUI_CTLSTAT) & R128_PC_BUSY)) { |
124 | return 0; | 123 | return 0; |
125 | } | 124 | } |
126 | DRM_UDELAY( 1 ); | 125 | DRM_UDELAY(1); |
127 | } | 126 | } |
128 | 127 | ||
129 | #if R128_FIFO_DEBUG | 128 | #if R128_FIFO_DEBUG |
130 | DRM_ERROR( "failed!\n" ); | 129 | DRM_ERROR("failed!\n"); |
131 | #endif | 130 | #endif |
132 | return DRM_ERR(EBUSY); | 131 | return DRM_ERR(EBUSY); |
133 | } | 132 | } |
134 | 133 | ||
135 | static int r128_do_wait_for_fifo( drm_r128_private_t *dev_priv, int entries ) | 134 | static int r128_do_wait_for_fifo(drm_r128_private_t * dev_priv, int entries) |
136 | { | 135 | { |
137 | int i; | 136 | int i; |
138 | 137 | ||
139 | for ( i = 0 ; i < dev_priv->usec_timeout ; i++ ) { | 138 | for (i = 0; i < dev_priv->usec_timeout; i++) { |
140 | int slots = R128_READ( R128_GUI_STAT ) & R128_GUI_FIFOCNT_MASK; | 139 | int slots = R128_READ(R128_GUI_STAT) & R128_GUI_FIFOCNT_MASK; |
141 | if ( slots >= entries ) return 0; | 140 | if (slots >= entries) |
142 | DRM_UDELAY( 1 ); | 141 | return 0; |
142 | DRM_UDELAY(1); | ||
143 | } | 143 | } |
144 | 144 | ||
145 | #if R128_FIFO_DEBUG | 145 | #if R128_FIFO_DEBUG |
146 | DRM_ERROR( "failed!\n" ); | 146 | DRM_ERROR("failed!\n"); |
147 | #endif | 147 | #endif |
148 | return DRM_ERR(EBUSY); | 148 | return DRM_ERR(EBUSY); |
149 | } | 149 | } |
150 | 150 | ||
151 | static int r128_do_wait_for_idle( drm_r128_private_t *dev_priv ) | 151 | static int r128_do_wait_for_idle(drm_r128_private_t * dev_priv) |
152 | { | 152 | { |
153 | int i, ret; | 153 | int i, ret; |
154 | 154 | ||
155 | ret = r128_do_wait_for_fifo( dev_priv, 64 ); | 155 | ret = r128_do_wait_for_fifo(dev_priv, 64); |
156 | if ( ret ) return ret; | 156 | if (ret) |
157 | return ret; | ||
157 | 158 | ||
158 | for ( i = 0 ; i < dev_priv->usec_timeout ; i++ ) { | 159 | for (i = 0; i < dev_priv->usec_timeout; i++) { |
159 | if ( !(R128_READ( R128_GUI_STAT ) & R128_GUI_ACTIVE) ) { | 160 | if (!(R128_READ(R128_GUI_STAT) & R128_GUI_ACTIVE)) { |
160 | r128_do_pixcache_flush( dev_priv ); | 161 | r128_do_pixcache_flush(dev_priv); |
161 | return 0; | 162 | return 0; |
162 | } | 163 | } |
163 | DRM_UDELAY( 1 ); | 164 | DRM_UDELAY(1); |
164 | } | 165 | } |
165 | 166 | ||
166 | #if R128_FIFO_DEBUG | 167 | #if R128_FIFO_DEBUG |
167 | DRM_ERROR( "failed!\n" ); | 168 | DRM_ERROR("failed!\n"); |
168 | #endif | 169 | #endif |
169 | return DRM_ERR(EBUSY); | 170 | return DRM_ERR(EBUSY); |
170 | } | 171 | } |
171 | 172 | ||
172 | |||
173 | /* ================================================================ | 173 | /* ================================================================ |
174 | * CCE control, initialization | 174 | * CCE control, initialization |
175 | */ | 175 | */ |
176 | 176 | ||
177 | /* Load the microcode for the CCE */ | 177 | /* Load the microcode for the CCE */ |
178 | static void r128_cce_load_microcode( drm_r128_private_t *dev_priv ) | 178 | static void r128_cce_load_microcode(drm_r128_private_t * dev_priv) |
179 | { | 179 | { |
180 | int i; | 180 | int i; |
181 | 181 | ||
182 | DRM_DEBUG( "\n" ); | 182 | DRM_DEBUG("\n"); |
183 | 183 | ||
184 | r128_do_wait_for_idle( dev_priv ); | 184 | r128_do_wait_for_idle(dev_priv); |
185 | 185 | ||
186 | R128_WRITE( R128_PM4_MICROCODE_ADDR, 0 ); | 186 | R128_WRITE(R128_PM4_MICROCODE_ADDR, 0); |
187 | for ( i = 0 ; i < 256 ; i++ ) { | 187 | for (i = 0; i < 256; i++) { |
188 | R128_WRITE( R128_PM4_MICROCODE_DATAH, | 188 | R128_WRITE(R128_PM4_MICROCODE_DATAH, r128_cce_microcode[i * 2]); |
189 | r128_cce_microcode[i * 2] ); | 189 | R128_WRITE(R128_PM4_MICROCODE_DATAL, |
190 | R128_WRITE( R128_PM4_MICROCODE_DATAL, | 190 | r128_cce_microcode[i * 2 + 1]); |
191 | r128_cce_microcode[i * 2 + 1] ); | ||
192 | } | 191 | } |
193 | } | 192 | } |
194 | 193 | ||
@@ -196,51 +195,51 @@ static void r128_cce_load_microcode( drm_r128_private_t *dev_priv ) | |||
196 | * prior to a wait for idle, as it informs the engine that the command | 195 | * prior to a wait for idle, as it informs the engine that the command |
197 | * stream is ending. | 196 | * stream is ending. |
198 | */ | 197 | */ |
199 | static void r128_do_cce_flush( drm_r128_private_t *dev_priv ) | 198 | static void r128_do_cce_flush(drm_r128_private_t * dev_priv) |
200 | { | 199 | { |
201 | u32 tmp; | 200 | u32 tmp; |
202 | 201 | ||
203 | tmp = R128_READ( R128_PM4_BUFFER_DL_WPTR ) | R128_PM4_BUFFER_DL_DONE; | 202 | tmp = R128_READ(R128_PM4_BUFFER_DL_WPTR) | R128_PM4_BUFFER_DL_DONE; |
204 | R128_WRITE( R128_PM4_BUFFER_DL_WPTR, tmp ); | 203 | R128_WRITE(R128_PM4_BUFFER_DL_WPTR, tmp); |
205 | } | 204 | } |
206 | 205 | ||
207 | /* Wait for the CCE to go idle. | 206 | /* Wait for the CCE to go idle. |
208 | */ | 207 | */ |
209 | int r128_do_cce_idle( drm_r128_private_t *dev_priv ) | 208 | int r128_do_cce_idle(drm_r128_private_t * dev_priv) |
210 | { | 209 | { |
211 | int i; | 210 | int i; |
212 | 211 | ||
213 | for ( i = 0 ; i < dev_priv->usec_timeout ; i++ ) { | 212 | for (i = 0; i < dev_priv->usec_timeout; i++) { |
214 | if ( GET_RING_HEAD( dev_priv ) == dev_priv->ring.tail ) { | 213 | if (GET_RING_HEAD(dev_priv) == dev_priv->ring.tail) { |
215 | int pm4stat = R128_READ( R128_PM4_STAT ); | 214 | int pm4stat = R128_READ(R128_PM4_STAT); |
216 | if ( ( (pm4stat & R128_PM4_FIFOCNT_MASK) >= | 215 | if (((pm4stat & R128_PM4_FIFOCNT_MASK) >= |
217 | dev_priv->cce_fifo_size ) && | 216 | dev_priv->cce_fifo_size) && |
218 | !(pm4stat & (R128_PM4_BUSY | | 217 | !(pm4stat & (R128_PM4_BUSY | |
219 | R128_PM4_GUI_ACTIVE)) ) { | 218 | R128_PM4_GUI_ACTIVE))) { |
220 | return r128_do_pixcache_flush( dev_priv ); | 219 | return r128_do_pixcache_flush(dev_priv); |
221 | } | 220 | } |
222 | } | 221 | } |
223 | DRM_UDELAY( 1 ); | 222 | DRM_UDELAY(1); |
224 | } | 223 | } |
225 | 224 | ||
226 | #if R128_FIFO_DEBUG | 225 | #if R128_FIFO_DEBUG |
227 | DRM_ERROR( "failed!\n" ); | 226 | DRM_ERROR("failed!\n"); |
228 | r128_status( dev_priv ); | 227 | r128_status(dev_priv); |
229 | #endif | 228 | #endif |
230 | return DRM_ERR(EBUSY); | 229 | return DRM_ERR(EBUSY); |
231 | } | 230 | } |
232 | 231 | ||
233 | /* Start the Concurrent Command Engine. | 232 | /* Start the Concurrent Command Engine. |
234 | */ | 233 | */ |
235 | static void r128_do_cce_start( drm_r128_private_t *dev_priv ) | 234 | static void r128_do_cce_start(drm_r128_private_t * dev_priv) |
236 | { | 235 | { |
237 | r128_do_wait_for_idle( dev_priv ); | 236 | r128_do_wait_for_idle(dev_priv); |
238 | 237 | ||
239 | R128_WRITE( R128_PM4_BUFFER_CNTL, | 238 | R128_WRITE(R128_PM4_BUFFER_CNTL, |
240 | dev_priv->cce_mode | dev_priv->ring.size_l2qw | 239 | dev_priv->cce_mode | dev_priv->ring.size_l2qw |
241 | | R128_PM4_BUFFER_CNTL_NOUPDATE ); | 240 | | R128_PM4_BUFFER_CNTL_NOUPDATE); |
242 | R128_READ( R128_PM4_BUFFER_ADDR ); /* as per the sample code */ | 241 | R128_READ(R128_PM4_BUFFER_ADDR); /* as per the sample code */ |
243 | R128_WRITE( R128_PM4_MICRO_CNTL, R128_PM4_MICRO_FREERUN ); | 242 | R128_WRITE(R128_PM4_MICRO_CNTL, R128_PM4_MICRO_FREERUN); |
244 | 243 | ||
245 | dev_priv->cce_running = 1; | 244 | dev_priv->cce_running = 1; |
246 | } | 245 | } |
@@ -249,10 +248,10 @@ static void r128_do_cce_start( drm_r128_private_t *dev_priv ) | |||
249 | * commands, so you must wait for the CCE command stream to complete | 248 | * commands, so you must wait for the CCE command stream to complete |
250 | * before calling this routine. | 249 | * before calling this routine. |
251 | */ | 250 | */ |
252 | static void r128_do_cce_reset( drm_r128_private_t *dev_priv ) | 251 | static void r128_do_cce_reset(drm_r128_private_t * dev_priv) |
253 | { | 252 | { |
254 | R128_WRITE( R128_PM4_BUFFER_DL_WPTR, 0 ); | 253 | R128_WRITE(R128_PM4_BUFFER_DL_WPTR, 0); |
255 | R128_WRITE( R128_PM4_BUFFER_DL_RPTR, 0 ); | 254 | R128_WRITE(R128_PM4_BUFFER_DL_RPTR, 0); |
256 | dev_priv->ring.tail = 0; | 255 | dev_priv->ring.tail = 0; |
257 | } | 256 | } |
258 | 257 | ||
@@ -260,122 +259,120 @@ static void r128_do_cce_reset( drm_r128_private_t *dev_priv ) | |||
260 | * commands, so you must flush the command stream and wait for the CCE | 259 | * commands, so you must flush the command stream and wait for the CCE |
261 | * to go idle before calling this routine. | 260 | * to go idle before calling this routine. |
262 | */ | 261 | */ |
263 | static void r128_do_cce_stop( drm_r128_private_t *dev_priv ) | 262 | static void r128_do_cce_stop(drm_r128_private_t * dev_priv) |
264 | { | 263 | { |
265 | R128_WRITE( R128_PM4_MICRO_CNTL, 0 ); | 264 | R128_WRITE(R128_PM4_MICRO_CNTL, 0); |
266 | R128_WRITE( R128_PM4_BUFFER_CNTL, | 265 | R128_WRITE(R128_PM4_BUFFER_CNTL, |
267 | R128_PM4_NONPM4 | R128_PM4_BUFFER_CNTL_NOUPDATE ); | 266 | R128_PM4_NONPM4 | R128_PM4_BUFFER_CNTL_NOUPDATE); |
268 | 267 | ||
269 | dev_priv->cce_running = 0; | 268 | dev_priv->cce_running = 0; |
270 | } | 269 | } |
271 | 270 | ||
272 | /* Reset the engine. This will stop the CCE if it is running. | 271 | /* Reset the engine. This will stop the CCE if it is running. |
273 | */ | 272 | */ |
274 | static int r128_do_engine_reset( drm_device_t *dev ) | 273 | static int r128_do_engine_reset(drm_device_t * dev) |
275 | { | 274 | { |
276 | drm_r128_private_t *dev_priv = dev->dev_private; | 275 | drm_r128_private_t *dev_priv = dev->dev_private; |
277 | u32 clock_cntl_index, mclk_cntl, gen_reset_cntl; | 276 | u32 clock_cntl_index, mclk_cntl, gen_reset_cntl; |
278 | 277 | ||
279 | r128_do_pixcache_flush( dev_priv ); | 278 | r128_do_pixcache_flush(dev_priv); |
280 | 279 | ||
281 | clock_cntl_index = R128_READ( R128_CLOCK_CNTL_INDEX ); | 280 | clock_cntl_index = R128_READ(R128_CLOCK_CNTL_INDEX); |
282 | mclk_cntl = R128_READ_PLL( dev, R128_MCLK_CNTL ); | 281 | mclk_cntl = R128_READ_PLL(dev, R128_MCLK_CNTL); |
283 | 282 | ||
284 | R128_WRITE_PLL( R128_MCLK_CNTL, | 283 | R128_WRITE_PLL(R128_MCLK_CNTL, |
285 | mclk_cntl | R128_FORCE_GCP | R128_FORCE_PIPE3D_CP ); | 284 | mclk_cntl | R128_FORCE_GCP | R128_FORCE_PIPE3D_CP); |
286 | 285 | ||
287 | gen_reset_cntl = R128_READ( R128_GEN_RESET_CNTL ); | 286 | gen_reset_cntl = R128_READ(R128_GEN_RESET_CNTL); |
288 | 287 | ||
289 | /* Taken from the sample code - do not change */ | 288 | /* Taken from the sample code - do not change */ |
290 | R128_WRITE( R128_GEN_RESET_CNTL, | 289 | R128_WRITE(R128_GEN_RESET_CNTL, gen_reset_cntl | R128_SOFT_RESET_GUI); |
291 | gen_reset_cntl | R128_SOFT_RESET_GUI ); | 290 | R128_READ(R128_GEN_RESET_CNTL); |
292 | R128_READ( R128_GEN_RESET_CNTL ); | 291 | R128_WRITE(R128_GEN_RESET_CNTL, gen_reset_cntl & ~R128_SOFT_RESET_GUI); |
293 | R128_WRITE( R128_GEN_RESET_CNTL, | 292 | R128_READ(R128_GEN_RESET_CNTL); |
294 | gen_reset_cntl & ~R128_SOFT_RESET_GUI ); | ||
295 | R128_READ( R128_GEN_RESET_CNTL ); | ||
296 | 293 | ||
297 | R128_WRITE_PLL( R128_MCLK_CNTL, mclk_cntl ); | 294 | R128_WRITE_PLL(R128_MCLK_CNTL, mclk_cntl); |
298 | R128_WRITE( R128_CLOCK_CNTL_INDEX, clock_cntl_index ); | 295 | R128_WRITE(R128_CLOCK_CNTL_INDEX, clock_cntl_index); |
299 | R128_WRITE( R128_GEN_RESET_CNTL, gen_reset_cntl ); | 296 | R128_WRITE(R128_GEN_RESET_CNTL, gen_reset_cntl); |
300 | 297 | ||
301 | /* Reset the CCE ring */ | 298 | /* Reset the CCE ring */ |
302 | r128_do_cce_reset( dev_priv ); | 299 | r128_do_cce_reset(dev_priv); |
303 | 300 | ||
304 | /* The CCE is no longer running after an engine reset */ | 301 | /* The CCE is no longer running after an engine reset */ |
305 | dev_priv->cce_running = 0; | 302 | dev_priv->cce_running = 0; |
306 | 303 | ||
307 | /* Reset any pending vertex, indirect buffers */ | 304 | /* Reset any pending vertex, indirect buffers */ |
308 | r128_freelist_reset( dev ); | 305 | r128_freelist_reset(dev); |
309 | 306 | ||
310 | return 0; | 307 | return 0; |
311 | } | 308 | } |
312 | 309 | ||
313 | static void r128_cce_init_ring_buffer( drm_device_t *dev, | 310 | static void r128_cce_init_ring_buffer(drm_device_t * dev, |
314 | drm_r128_private_t *dev_priv ) | 311 | drm_r128_private_t * dev_priv) |
315 | { | 312 | { |
316 | u32 ring_start; | 313 | u32 ring_start; |
317 | u32 tmp; | 314 | u32 tmp; |
318 | 315 | ||
319 | DRM_DEBUG( "\n" ); | 316 | DRM_DEBUG("\n"); |
320 | 317 | ||
321 | /* The manual (p. 2) says this address is in "VM space". This | 318 | /* The manual (p. 2) says this address is in "VM space". This |
322 | * means it's an offset from the start of AGP space. | 319 | * means it's an offset from the start of AGP space. |
323 | */ | 320 | */ |
324 | #if __OS_HAS_AGP | 321 | #if __OS_HAS_AGP |
325 | if ( !dev_priv->is_pci ) | 322 | if (!dev_priv->is_pci) |
326 | ring_start = dev_priv->cce_ring->offset - dev->agp->base; | 323 | ring_start = dev_priv->cce_ring->offset - dev->agp->base; |
327 | else | 324 | else |
328 | #endif | 325 | #endif |
329 | ring_start = dev_priv->cce_ring->offset - | 326 | ring_start = dev_priv->cce_ring->offset - |
330 | (unsigned long)dev->sg->virtual; | 327 | (unsigned long)dev->sg->virtual; |
331 | 328 | ||
332 | R128_WRITE( R128_PM4_BUFFER_OFFSET, ring_start | R128_AGP_OFFSET ); | 329 | R128_WRITE(R128_PM4_BUFFER_OFFSET, ring_start | R128_AGP_OFFSET); |
333 | 330 | ||
334 | R128_WRITE( R128_PM4_BUFFER_DL_WPTR, 0 ); | 331 | R128_WRITE(R128_PM4_BUFFER_DL_WPTR, 0); |
335 | R128_WRITE( R128_PM4_BUFFER_DL_RPTR, 0 ); | 332 | R128_WRITE(R128_PM4_BUFFER_DL_RPTR, 0); |
336 | 333 | ||
337 | /* Set watermark control */ | 334 | /* Set watermark control */ |
338 | R128_WRITE( R128_PM4_BUFFER_WM_CNTL, | 335 | R128_WRITE(R128_PM4_BUFFER_WM_CNTL, |
339 | ((R128_WATERMARK_L/4) << R128_WMA_SHIFT) | 336 | ((R128_WATERMARK_L / 4) << R128_WMA_SHIFT) |
340 | | ((R128_WATERMARK_M/4) << R128_WMB_SHIFT) | 337 | | ((R128_WATERMARK_M / 4) << R128_WMB_SHIFT) |
341 | | ((R128_WATERMARK_N/4) << R128_WMC_SHIFT) | 338 | | ((R128_WATERMARK_N / 4) << R128_WMC_SHIFT) |
342 | | ((R128_WATERMARK_K/64) << R128_WB_WM_SHIFT) ); | 339 | | ((R128_WATERMARK_K / 64) << R128_WB_WM_SHIFT)); |
343 | 340 | ||
344 | /* Force read. Why? Because it's in the examples... */ | 341 | /* Force read. Why? Because it's in the examples... */ |
345 | R128_READ( R128_PM4_BUFFER_ADDR ); | 342 | R128_READ(R128_PM4_BUFFER_ADDR); |
346 | 343 | ||
347 | /* Turn on bus mastering */ | 344 | /* Turn on bus mastering */ |
348 | tmp = R128_READ( R128_BUS_CNTL ) & ~R128_BUS_MASTER_DIS; | 345 | tmp = R128_READ(R128_BUS_CNTL) & ~R128_BUS_MASTER_DIS; |
349 | R128_WRITE( R128_BUS_CNTL, tmp ); | 346 | R128_WRITE(R128_BUS_CNTL, tmp); |
350 | } | 347 | } |
351 | 348 | ||
352 | static int r128_do_init_cce( drm_device_t *dev, drm_r128_init_t *init ) | 349 | static int r128_do_init_cce(drm_device_t * dev, drm_r128_init_t * init) |
353 | { | 350 | { |
354 | drm_r128_private_t *dev_priv; | 351 | drm_r128_private_t *dev_priv; |
355 | 352 | ||
356 | DRM_DEBUG( "\n" ); | 353 | DRM_DEBUG("\n"); |
357 | 354 | ||
358 | dev_priv = drm_alloc( sizeof(drm_r128_private_t), DRM_MEM_DRIVER ); | 355 | dev_priv = drm_alloc(sizeof(drm_r128_private_t), DRM_MEM_DRIVER); |
359 | if ( dev_priv == NULL ) | 356 | if (dev_priv == NULL) |
360 | return DRM_ERR(ENOMEM); | 357 | return DRM_ERR(ENOMEM); |
361 | 358 | ||
362 | memset( dev_priv, 0, sizeof(drm_r128_private_t) ); | 359 | memset(dev_priv, 0, sizeof(drm_r128_private_t)); |
363 | 360 | ||
364 | dev_priv->is_pci = init->is_pci; | 361 | dev_priv->is_pci = init->is_pci; |
365 | 362 | ||
366 | if ( dev_priv->is_pci && !dev->sg ) { | 363 | if (dev_priv->is_pci && !dev->sg) { |
367 | DRM_ERROR( "PCI GART memory not allocated!\n" ); | 364 | DRM_ERROR("PCI GART memory not allocated!\n"); |
368 | dev->dev_private = (void *)dev_priv; | 365 | dev->dev_private = (void *)dev_priv; |
369 | r128_do_cleanup_cce( dev ); | 366 | r128_do_cleanup_cce(dev); |
370 | return DRM_ERR(EINVAL); | 367 | return DRM_ERR(EINVAL); |
371 | } | 368 | } |
372 | 369 | ||
373 | dev_priv->usec_timeout = init->usec_timeout; | 370 | dev_priv->usec_timeout = init->usec_timeout; |
374 | if ( dev_priv->usec_timeout < 1 || | 371 | if (dev_priv->usec_timeout < 1 || |
375 | dev_priv->usec_timeout > R128_MAX_USEC_TIMEOUT ) { | 372 | dev_priv->usec_timeout > R128_MAX_USEC_TIMEOUT) { |
376 | DRM_DEBUG( "TIMEOUT problem!\n" ); | 373 | DRM_DEBUG("TIMEOUT problem!\n"); |
377 | dev->dev_private = (void *)dev_priv; | 374 | dev->dev_private = (void *)dev_priv; |
378 | r128_do_cleanup_cce( dev ); | 375 | r128_do_cleanup_cce(dev); |
379 | return DRM_ERR(EINVAL); | 376 | return DRM_ERR(EINVAL); |
380 | } | 377 | } |
381 | 378 | ||
@@ -383,23 +380,23 @@ static int r128_do_init_cce( drm_device_t *dev, drm_r128_init_t *init ) | |||
383 | 380 | ||
384 | /* GH: Simple idle check. | 381 | /* GH: Simple idle check. |
385 | */ | 382 | */ |
386 | atomic_set( &dev_priv->idle_count, 0 ); | 383 | atomic_set(&dev_priv->idle_count, 0); |
387 | 384 | ||
388 | /* We don't support anything other than bus-mastering ring mode, | 385 | /* We don't support anything other than bus-mastering ring mode, |
389 | * but the ring can be in either AGP or PCI space for the ring | 386 | * but the ring can be in either AGP or PCI space for the ring |
390 | * read pointer. | 387 | * read pointer. |
391 | */ | 388 | */ |
392 | if ( ( init->cce_mode != R128_PM4_192BM ) && | 389 | if ((init->cce_mode != R128_PM4_192BM) && |
393 | ( init->cce_mode != R128_PM4_128BM_64INDBM ) && | 390 | (init->cce_mode != R128_PM4_128BM_64INDBM) && |
394 | ( init->cce_mode != R128_PM4_64BM_128INDBM ) && | 391 | (init->cce_mode != R128_PM4_64BM_128INDBM) && |
395 | ( init->cce_mode != R128_PM4_64BM_64VCBM_64INDBM ) ) { | 392 | (init->cce_mode != R128_PM4_64BM_64VCBM_64INDBM)) { |
396 | DRM_DEBUG( "Bad cce_mode!\n" ); | 393 | DRM_DEBUG("Bad cce_mode!\n"); |
397 | dev->dev_private = (void *)dev_priv; | 394 | dev->dev_private = (void *)dev_priv; |
398 | r128_do_cleanup_cce( dev ); | 395 | r128_do_cleanup_cce(dev); |
399 | return DRM_ERR(EINVAL); | 396 | return DRM_ERR(EINVAL); |
400 | } | 397 | } |
401 | 398 | ||
402 | switch ( init->cce_mode ) { | 399 | switch (init->cce_mode) { |
403 | case R128_PM4_NONPM4: | 400 | case R128_PM4_NONPM4: |
404 | dev_priv->cce_fifo_size = 0; | 401 | dev_priv->cce_fifo_size = 0; |
405 | break; | 402 | break; |
@@ -420,7 +417,7 @@ static int r128_do_init_cce( drm_device_t *dev, drm_r128_init_t *init ) | |||
420 | break; | 417 | break; |
421 | } | 418 | } |
422 | 419 | ||
423 | switch ( init->fb_bpp ) { | 420 | switch (init->fb_bpp) { |
424 | case 16: | 421 | case 16: |
425 | dev_priv->color_fmt = R128_DATATYPE_RGB565; | 422 | dev_priv->color_fmt = R128_DATATYPE_RGB565; |
426 | break; | 423 | break; |
@@ -429,12 +426,12 @@ static int r128_do_init_cce( drm_device_t *dev, drm_r128_init_t *init ) | |||
429 | dev_priv->color_fmt = R128_DATATYPE_ARGB8888; | 426 | dev_priv->color_fmt = R128_DATATYPE_ARGB8888; |
430 | break; | 427 | break; |
431 | } | 428 | } |
432 | dev_priv->front_offset = init->front_offset; | 429 | dev_priv->front_offset = init->front_offset; |
433 | dev_priv->front_pitch = init->front_pitch; | 430 | dev_priv->front_pitch = init->front_pitch; |
434 | dev_priv->back_offset = init->back_offset; | 431 | dev_priv->back_offset = init->back_offset; |
435 | dev_priv->back_pitch = init->back_pitch; | 432 | dev_priv->back_pitch = init->back_pitch; |
436 | 433 | ||
437 | switch ( init->depth_bpp ) { | 434 | switch (init->depth_bpp) { |
438 | case 16: | 435 | case 16: |
439 | dev_priv->depth_fmt = R128_DATATYPE_RGB565; | 436 | dev_priv->depth_fmt = R128_DATATYPE_RGB565; |
440 | break; | 437 | break; |
@@ -444,131 +441,130 @@ static int r128_do_init_cce( drm_device_t *dev, drm_r128_init_t *init ) | |||
444 | dev_priv->depth_fmt = R128_DATATYPE_ARGB8888; | 441 | dev_priv->depth_fmt = R128_DATATYPE_ARGB8888; |
445 | break; | 442 | break; |
446 | } | 443 | } |
447 | dev_priv->depth_offset = init->depth_offset; | 444 | dev_priv->depth_offset = init->depth_offset; |
448 | dev_priv->depth_pitch = init->depth_pitch; | 445 | dev_priv->depth_pitch = init->depth_pitch; |
449 | dev_priv->span_offset = init->span_offset; | 446 | dev_priv->span_offset = init->span_offset; |
450 | 447 | ||
451 | dev_priv->front_pitch_offset_c = (((dev_priv->front_pitch/8) << 21) | | 448 | dev_priv->front_pitch_offset_c = (((dev_priv->front_pitch / 8) << 21) | |
452 | (dev_priv->front_offset >> 5)); | 449 | (dev_priv->front_offset >> 5)); |
453 | dev_priv->back_pitch_offset_c = (((dev_priv->back_pitch/8) << 21) | | 450 | dev_priv->back_pitch_offset_c = (((dev_priv->back_pitch / 8) << 21) | |
454 | (dev_priv->back_offset >> 5)); | 451 | (dev_priv->back_offset >> 5)); |
455 | dev_priv->depth_pitch_offset_c = (((dev_priv->depth_pitch/8) << 21) | | 452 | dev_priv->depth_pitch_offset_c = (((dev_priv->depth_pitch / 8) << 21) | |
456 | (dev_priv->depth_offset >> 5) | | 453 | (dev_priv->depth_offset >> 5) | |
457 | R128_DST_TILE); | 454 | R128_DST_TILE); |
458 | dev_priv->span_pitch_offset_c = (((dev_priv->depth_pitch/8) << 21) | | 455 | dev_priv->span_pitch_offset_c = (((dev_priv->depth_pitch / 8) << 21) | |
459 | (dev_priv->span_offset >> 5)); | 456 | (dev_priv->span_offset >> 5)); |
460 | 457 | ||
461 | DRM_GETSAREA(); | 458 | DRM_GETSAREA(); |
462 | 459 | ||
463 | if(!dev_priv->sarea) { | 460 | if (!dev_priv->sarea) { |
464 | DRM_ERROR("could not find sarea!\n"); | 461 | DRM_ERROR("could not find sarea!\n"); |
465 | dev->dev_private = (void *)dev_priv; | 462 | dev->dev_private = (void *)dev_priv; |
466 | r128_do_cleanup_cce( dev ); | 463 | r128_do_cleanup_cce(dev); |
467 | return DRM_ERR(EINVAL); | 464 | return DRM_ERR(EINVAL); |
468 | } | 465 | } |
469 | 466 | ||
470 | dev_priv->mmio = drm_core_findmap(dev, init->mmio_offset); | 467 | dev_priv->mmio = drm_core_findmap(dev, init->mmio_offset); |
471 | if(!dev_priv->mmio) { | 468 | if (!dev_priv->mmio) { |
472 | DRM_ERROR("could not find mmio region!\n"); | 469 | DRM_ERROR("could not find mmio region!\n"); |
473 | dev->dev_private = (void *)dev_priv; | 470 | dev->dev_private = (void *)dev_priv; |
474 | r128_do_cleanup_cce( dev ); | 471 | r128_do_cleanup_cce(dev); |
475 | return DRM_ERR(EINVAL); | 472 | return DRM_ERR(EINVAL); |
476 | } | 473 | } |
477 | dev_priv->cce_ring = drm_core_findmap(dev, init->ring_offset); | 474 | dev_priv->cce_ring = drm_core_findmap(dev, init->ring_offset); |
478 | if(!dev_priv->cce_ring) { | 475 | if (!dev_priv->cce_ring) { |
479 | DRM_ERROR("could not find cce ring region!\n"); | 476 | DRM_ERROR("could not find cce ring region!\n"); |
480 | dev->dev_private = (void *)dev_priv; | 477 | dev->dev_private = (void *)dev_priv; |
481 | r128_do_cleanup_cce( dev ); | 478 | r128_do_cleanup_cce(dev); |
482 | return DRM_ERR(EINVAL); | 479 | return DRM_ERR(EINVAL); |
483 | } | 480 | } |
484 | dev_priv->ring_rptr = drm_core_findmap(dev, init->ring_rptr_offset); | 481 | dev_priv->ring_rptr = drm_core_findmap(dev, init->ring_rptr_offset); |
485 | if(!dev_priv->ring_rptr) { | 482 | if (!dev_priv->ring_rptr) { |
486 | DRM_ERROR("could not find ring read pointer!\n"); | 483 | DRM_ERROR("could not find ring read pointer!\n"); |
487 | dev->dev_private = (void *)dev_priv; | 484 | dev->dev_private = (void *)dev_priv; |
488 | r128_do_cleanup_cce( dev ); | 485 | r128_do_cleanup_cce(dev); |
489 | return DRM_ERR(EINVAL); | 486 | return DRM_ERR(EINVAL); |
490 | } | 487 | } |
491 | dev->agp_buffer_token = init->buffers_offset; | 488 | dev->agp_buffer_token = init->buffers_offset; |
492 | dev->agp_buffer_map = drm_core_findmap(dev, init->buffers_offset); | 489 | dev->agp_buffer_map = drm_core_findmap(dev, init->buffers_offset); |
493 | if(!dev->agp_buffer_map) { | 490 | if (!dev->agp_buffer_map) { |
494 | DRM_ERROR("could not find dma buffer region!\n"); | 491 | DRM_ERROR("could not find dma buffer region!\n"); |
495 | dev->dev_private = (void *)dev_priv; | 492 | dev->dev_private = (void *)dev_priv; |
496 | r128_do_cleanup_cce( dev ); | 493 | r128_do_cleanup_cce(dev); |
497 | return DRM_ERR(EINVAL); | 494 | return DRM_ERR(EINVAL); |
498 | } | 495 | } |
499 | 496 | ||
500 | if ( !dev_priv->is_pci ) { | 497 | if (!dev_priv->is_pci) { |
501 | dev_priv->agp_textures = drm_core_findmap(dev, init->agp_textures_offset); | 498 | dev_priv->agp_textures = |
502 | if(!dev_priv->agp_textures) { | 499 | drm_core_findmap(dev, init->agp_textures_offset); |
500 | if (!dev_priv->agp_textures) { | ||
503 | DRM_ERROR("could not find agp texture region!\n"); | 501 | DRM_ERROR("could not find agp texture region!\n"); |
504 | dev->dev_private = (void *)dev_priv; | 502 | dev->dev_private = (void *)dev_priv; |
505 | r128_do_cleanup_cce( dev ); | 503 | r128_do_cleanup_cce(dev); |
506 | return DRM_ERR(EINVAL); | 504 | return DRM_ERR(EINVAL); |
507 | } | 505 | } |
508 | } | 506 | } |
509 | 507 | ||
510 | dev_priv->sarea_priv = | 508 | dev_priv->sarea_priv = |
511 | (drm_r128_sarea_t *)((u8 *)dev_priv->sarea->handle + | 509 | (drm_r128_sarea_t *) ((u8 *) dev_priv->sarea->handle + |
512 | init->sarea_priv_offset); | 510 | init->sarea_priv_offset); |
513 | 511 | ||
514 | #if __OS_HAS_AGP | 512 | #if __OS_HAS_AGP |
515 | if ( !dev_priv->is_pci ) { | 513 | if (!dev_priv->is_pci) { |
516 | drm_core_ioremap( dev_priv->cce_ring, dev ); | 514 | drm_core_ioremap(dev_priv->cce_ring, dev); |
517 | drm_core_ioremap( dev_priv->ring_rptr, dev ); | 515 | drm_core_ioremap(dev_priv->ring_rptr, dev); |
518 | drm_core_ioremap( dev->agp_buffer_map, dev ); | 516 | drm_core_ioremap(dev->agp_buffer_map, dev); |
519 | if(!dev_priv->cce_ring->handle || | 517 | if (!dev_priv->cce_ring->handle || |
520 | !dev_priv->ring_rptr->handle || | 518 | !dev_priv->ring_rptr->handle || |
521 | !dev->agp_buffer_map->handle) { | 519 | !dev->agp_buffer_map->handle) { |
522 | DRM_ERROR("Could not ioremap agp regions!\n"); | 520 | DRM_ERROR("Could not ioremap agp regions!\n"); |
523 | dev->dev_private = (void *)dev_priv; | 521 | dev->dev_private = (void *)dev_priv; |
524 | r128_do_cleanup_cce( dev ); | 522 | r128_do_cleanup_cce(dev); |
525 | return DRM_ERR(ENOMEM); | 523 | return DRM_ERR(ENOMEM); |
526 | } | 524 | } |
527 | } else | 525 | } else |
528 | #endif | 526 | #endif |
529 | { | 527 | { |
530 | dev_priv->cce_ring->handle = | 528 | dev_priv->cce_ring->handle = (void *)dev_priv->cce_ring->offset; |
531 | (void *)dev_priv->cce_ring->offset; | ||
532 | dev_priv->ring_rptr->handle = | 529 | dev_priv->ring_rptr->handle = |
533 | (void *)dev_priv->ring_rptr->offset; | 530 | (void *)dev_priv->ring_rptr->offset; |
534 | dev->agp_buffer_map->handle = (void *)dev->agp_buffer_map->offset; | 531 | dev->agp_buffer_map->handle = |
532 | (void *)dev->agp_buffer_map->offset; | ||
535 | } | 533 | } |
536 | 534 | ||
537 | #if __OS_HAS_AGP | 535 | #if __OS_HAS_AGP |
538 | if ( !dev_priv->is_pci ) | 536 | if (!dev_priv->is_pci) |
539 | dev_priv->cce_buffers_offset = dev->agp->base; | 537 | dev_priv->cce_buffers_offset = dev->agp->base; |
540 | else | 538 | else |
541 | #endif | 539 | #endif |
542 | dev_priv->cce_buffers_offset = (unsigned long)dev->sg->virtual; | 540 | dev_priv->cce_buffers_offset = (unsigned long)dev->sg->virtual; |
543 | 541 | ||
544 | dev_priv->ring.start = (u32 *)dev_priv->cce_ring->handle; | 542 | dev_priv->ring.start = (u32 *) dev_priv->cce_ring->handle; |
545 | dev_priv->ring.end = ((u32 *)dev_priv->cce_ring->handle | 543 | dev_priv->ring.end = ((u32 *) dev_priv->cce_ring->handle |
546 | + init->ring_size / sizeof(u32)); | 544 | + init->ring_size / sizeof(u32)); |
547 | dev_priv->ring.size = init->ring_size; | 545 | dev_priv->ring.size = init->ring_size; |
548 | dev_priv->ring.size_l2qw = drm_order( init->ring_size / 8 ); | 546 | dev_priv->ring.size_l2qw = drm_order(init->ring_size / 8); |
549 | 547 | ||
550 | dev_priv->ring.tail_mask = | 548 | dev_priv->ring.tail_mask = (dev_priv->ring.size / sizeof(u32)) - 1; |
551 | (dev_priv->ring.size / sizeof(u32)) - 1; | ||
552 | 549 | ||
553 | dev_priv->ring.high_mark = 128; | 550 | dev_priv->ring.high_mark = 128; |
554 | 551 | ||
555 | dev_priv->sarea_priv->last_frame = 0; | 552 | dev_priv->sarea_priv->last_frame = 0; |
556 | R128_WRITE( R128_LAST_FRAME_REG, dev_priv->sarea_priv->last_frame ); | 553 | R128_WRITE(R128_LAST_FRAME_REG, dev_priv->sarea_priv->last_frame); |
557 | 554 | ||
558 | dev_priv->sarea_priv->last_dispatch = 0; | 555 | dev_priv->sarea_priv->last_dispatch = 0; |
559 | R128_WRITE( R128_LAST_DISPATCH_REG, | 556 | R128_WRITE(R128_LAST_DISPATCH_REG, dev_priv->sarea_priv->last_dispatch); |
560 | dev_priv->sarea_priv->last_dispatch ); | ||
561 | 557 | ||
562 | #if __OS_HAS_AGP | 558 | #if __OS_HAS_AGP |
563 | if ( dev_priv->is_pci ) { | 559 | if (dev_priv->is_pci) { |
564 | #endif | 560 | #endif |
565 | dev_priv->gart_info.gart_table_location = DRM_ATI_GART_MAIN; | 561 | dev_priv->gart_info.gart_table_location = DRM_ATI_GART_MAIN; |
566 | dev_priv->gart_info.addr = dev_priv->gart_info.bus_addr = 0; | 562 | dev_priv->gart_info.addr = dev_priv->gart_info.bus_addr = 0; |
567 | dev_priv->gart_info.is_pcie = 0; | 563 | dev_priv->gart_info.is_pcie = 0; |
568 | if (!drm_ati_pcigart_init(dev, &dev_priv->gart_info)) { | 564 | if (!drm_ati_pcigart_init(dev, &dev_priv->gart_info)) { |
569 | DRM_ERROR( "failed to init PCI GART!\n" ); | 565 | DRM_ERROR("failed to init PCI GART!\n"); |
570 | dev->dev_private = (void *)dev_priv; | 566 | dev->dev_private = (void *)dev_priv; |
571 | r128_do_cleanup_cce( dev ); | 567 | r128_do_cleanup_cce(dev); |
572 | return DRM_ERR(ENOMEM); | 568 | return DRM_ERR(ENOMEM); |
573 | } | 569 | } |
574 | R128_WRITE(R128_PCI_GART_PAGE, dev_priv->gart_info.bus_addr); | 570 | R128_WRITE(R128_PCI_GART_PAGE, dev_priv->gart_info.bus_addr); |
@@ -576,88 +572,92 @@ static int r128_do_init_cce( drm_device_t *dev, drm_r128_init_t *init ) | |||
576 | } | 572 | } |
577 | #endif | 573 | #endif |
578 | 574 | ||
579 | r128_cce_init_ring_buffer( dev, dev_priv ); | 575 | r128_cce_init_ring_buffer(dev, dev_priv); |
580 | r128_cce_load_microcode( dev_priv ); | 576 | r128_cce_load_microcode(dev_priv); |
581 | 577 | ||
582 | dev->dev_private = (void *)dev_priv; | 578 | dev->dev_private = (void *)dev_priv; |
583 | 579 | ||
584 | r128_do_engine_reset( dev ); | 580 | r128_do_engine_reset(dev); |
585 | 581 | ||
586 | return 0; | 582 | return 0; |
587 | } | 583 | } |
588 | 584 | ||
589 | int r128_do_cleanup_cce( drm_device_t *dev ) | 585 | int r128_do_cleanup_cce(drm_device_t * dev) |
590 | { | 586 | { |
591 | 587 | ||
592 | /* Make sure interrupts are disabled here because the uninstall ioctl | 588 | /* Make sure interrupts are disabled here because the uninstall ioctl |
593 | * may not have been called from userspace and after dev_private | 589 | * may not have been called from userspace and after dev_private |
594 | * is freed, it's too late. | 590 | * is freed, it's too late. |
595 | */ | 591 | */ |
596 | if ( dev->irq_enabled ) drm_irq_uninstall(dev); | 592 | if (dev->irq_enabled) |
593 | drm_irq_uninstall(dev); | ||
597 | 594 | ||
598 | if ( dev->dev_private ) { | 595 | if (dev->dev_private) { |
599 | drm_r128_private_t *dev_priv = dev->dev_private; | 596 | drm_r128_private_t *dev_priv = dev->dev_private; |
600 | 597 | ||
601 | #if __OS_HAS_AGP | 598 | #if __OS_HAS_AGP |
602 | if ( !dev_priv->is_pci ) { | 599 | if (!dev_priv->is_pci) { |
603 | if ( dev_priv->cce_ring != NULL ) | 600 | if (dev_priv->cce_ring != NULL) |
604 | drm_core_ioremapfree( dev_priv->cce_ring, dev ); | 601 | drm_core_ioremapfree(dev_priv->cce_ring, dev); |
605 | if ( dev_priv->ring_rptr != NULL ) | 602 | if (dev_priv->ring_rptr != NULL) |
606 | drm_core_ioremapfree( dev_priv->ring_rptr, dev ); | 603 | drm_core_ioremapfree(dev_priv->ring_rptr, dev); |
607 | if ( dev->agp_buffer_map != NULL ) | 604 | if (dev->agp_buffer_map != NULL) |
608 | drm_core_ioremapfree( dev->agp_buffer_map, dev ); | 605 | drm_core_ioremapfree(dev->agp_buffer_map, dev); |
609 | } else | 606 | } else |
610 | #endif | 607 | #endif |
611 | { | 608 | { |
612 | if (dev_priv->gart_info.bus_addr) | 609 | if (dev_priv->gart_info.bus_addr) |
613 | if (!drm_ati_pcigart_cleanup( dev, | 610 | if (!drm_ati_pcigart_cleanup(dev, |
614 | &dev_priv->gart_info)) | 611 | &dev_priv-> |
615 | DRM_ERROR( "failed to cleanup PCI GART!\n" ); | 612 | gart_info)) |
613 | DRM_ERROR | ||
614 | ("failed to cleanup PCI GART!\n"); | ||
616 | } | 615 | } |
617 | 616 | ||
618 | drm_free( dev->dev_private, sizeof(drm_r128_private_t), | 617 | drm_free(dev->dev_private, sizeof(drm_r128_private_t), |
619 | DRM_MEM_DRIVER ); | 618 | DRM_MEM_DRIVER); |
620 | dev->dev_private = NULL; | 619 | dev->dev_private = NULL; |
621 | } | 620 | } |
622 | 621 | ||
623 | return 0; | 622 | return 0; |
624 | } | 623 | } |
625 | 624 | ||
626 | int r128_cce_init( DRM_IOCTL_ARGS ) | 625 | int r128_cce_init(DRM_IOCTL_ARGS) |
627 | { | 626 | { |
628 | DRM_DEVICE; | 627 | DRM_DEVICE; |
629 | drm_r128_init_t init; | 628 | drm_r128_init_t init; |
630 | 629 | ||
631 | DRM_DEBUG( "\n" ); | 630 | DRM_DEBUG("\n"); |
632 | 631 | ||
633 | LOCK_TEST_WITH_RETURN( dev, filp ); | 632 | LOCK_TEST_WITH_RETURN(dev, filp); |
634 | 633 | ||
635 | DRM_COPY_FROM_USER_IOCTL( init, (drm_r128_init_t __user *)data, sizeof(init) ); | 634 | DRM_COPY_FROM_USER_IOCTL(init, (drm_r128_init_t __user *) data, |
635 | sizeof(init)); | ||
636 | 636 | ||
637 | switch ( init.func ) { | 637 | switch (init.func) { |
638 | case R128_INIT_CCE: | 638 | case R128_INIT_CCE: |
639 | return r128_do_init_cce( dev, &init ); | 639 | return r128_do_init_cce(dev, &init); |
640 | case R128_CLEANUP_CCE: | 640 | case R128_CLEANUP_CCE: |
641 | return r128_do_cleanup_cce( dev ); | 641 | return r128_do_cleanup_cce(dev); |
642 | } | 642 | } |
643 | 643 | ||
644 | return DRM_ERR(EINVAL); | 644 | return DRM_ERR(EINVAL); |
645 | } | 645 | } |
646 | 646 | ||
647 | int r128_cce_start( DRM_IOCTL_ARGS ) | 647 | int r128_cce_start(DRM_IOCTL_ARGS) |
648 | { | 648 | { |
649 | DRM_DEVICE; | 649 | DRM_DEVICE; |
650 | drm_r128_private_t *dev_priv = dev->dev_private; | 650 | drm_r128_private_t *dev_priv = dev->dev_private; |
651 | DRM_DEBUG( "\n" ); | 651 | DRM_DEBUG("\n"); |
652 | 652 | ||
653 | LOCK_TEST_WITH_RETURN( dev, filp ); | 653 | LOCK_TEST_WITH_RETURN(dev, filp); |
654 | 654 | ||
655 | if ( dev_priv->cce_running || dev_priv->cce_mode == R128_PM4_NONPM4 ) { | 655 | if (dev_priv->cce_running || dev_priv->cce_mode == R128_PM4_NONPM4) { |
656 | DRM_DEBUG( "%s while CCE running\n", __FUNCTION__ ); | 656 | DRM_DEBUG("%s while CCE running\n", __FUNCTION__); |
657 | return 0; | 657 | return 0; |
658 | } | 658 | } |
659 | 659 | ||
660 | r128_do_cce_start( dev_priv ); | 660 | r128_do_cce_start(dev_priv); |
661 | 661 | ||
662 | return 0; | 662 | return 0; |
663 | } | 663 | } |
@@ -665,61 +665,63 @@ int r128_cce_start( DRM_IOCTL_ARGS ) | |||
665 | /* Stop the CCE. The engine must have been idled before calling this | 665 | /* Stop the CCE. The engine must have been idled before calling this |
666 | * routine. | 666 | * routine. |
667 | */ | 667 | */ |
668 | int r128_cce_stop( DRM_IOCTL_ARGS ) | 668 | int r128_cce_stop(DRM_IOCTL_ARGS) |
669 | { | 669 | { |
670 | DRM_DEVICE; | 670 | DRM_DEVICE; |
671 | drm_r128_private_t *dev_priv = dev->dev_private; | 671 | drm_r128_private_t *dev_priv = dev->dev_private; |
672 | drm_r128_cce_stop_t stop; | 672 | drm_r128_cce_stop_t stop; |
673 | int ret; | 673 | int ret; |
674 | DRM_DEBUG( "\n" ); | 674 | DRM_DEBUG("\n"); |
675 | 675 | ||
676 | LOCK_TEST_WITH_RETURN( dev, filp ); | 676 | LOCK_TEST_WITH_RETURN(dev, filp); |
677 | 677 | ||
678 | DRM_COPY_FROM_USER_IOCTL(stop, (drm_r128_cce_stop_t __user *)data, sizeof(stop) ); | 678 | DRM_COPY_FROM_USER_IOCTL(stop, (drm_r128_cce_stop_t __user *) data, |
679 | sizeof(stop)); | ||
679 | 680 | ||
680 | /* Flush any pending CCE commands. This ensures any outstanding | 681 | /* Flush any pending CCE commands. This ensures any outstanding |
681 | * commands are exectuted by the engine before we turn it off. | 682 | * commands are exectuted by the engine before we turn it off. |
682 | */ | 683 | */ |
683 | if ( stop.flush ) { | 684 | if (stop.flush) { |
684 | r128_do_cce_flush( dev_priv ); | 685 | r128_do_cce_flush(dev_priv); |
685 | } | 686 | } |
686 | 687 | ||
687 | /* If we fail to make the engine go idle, we return an error | 688 | /* If we fail to make the engine go idle, we return an error |
688 | * code so that the DRM ioctl wrapper can try again. | 689 | * code so that the DRM ioctl wrapper can try again. |
689 | */ | 690 | */ |
690 | if ( stop.idle ) { | 691 | if (stop.idle) { |
691 | ret = r128_do_cce_idle( dev_priv ); | 692 | ret = r128_do_cce_idle(dev_priv); |
692 | if ( ret ) return ret; | 693 | if (ret) |
694 | return ret; | ||
693 | } | 695 | } |
694 | 696 | ||
695 | /* Finally, we can turn off the CCE. If the engine isn't idle, | 697 | /* Finally, we can turn off the CCE. If the engine isn't idle, |
696 | * we will get some dropped triangles as they won't be fully | 698 | * we will get some dropped triangles as they won't be fully |
697 | * rendered before the CCE is shut down. | 699 | * rendered before the CCE is shut down. |
698 | */ | 700 | */ |
699 | r128_do_cce_stop( dev_priv ); | 701 | r128_do_cce_stop(dev_priv); |
700 | 702 | ||
701 | /* Reset the engine */ | 703 | /* Reset the engine */ |
702 | r128_do_engine_reset( dev ); | 704 | r128_do_engine_reset(dev); |
703 | 705 | ||
704 | return 0; | 706 | return 0; |
705 | } | 707 | } |
706 | 708 | ||
707 | /* Just reset the CCE ring. Called as part of an X Server engine reset. | 709 | /* Just reset the CCE ring. Called as part of an X Server engine reset. |
708 | */ | 710 | */ |
709 | int r128_cce_reset( DRM_IOCTL_ARGS ) | 711 | int r128_cce_reset(DRM_IOCTL_ARGS) |
710 | { | 712 | { |
711 | DRM_DEVICE; | 713 | DRM_DEVICE; |
712 | drm_r128_private_t *dev_priv = dev->dev_private; | 714 | drm_r128_private_t *dev_priv = dev->dev_private; |
713 | DRM_DEBUG( "\n" ); | 715 | DRM_DEBUG("\n"); |
714 | 716 | ||
715 | LOCK_TEST_WITH_RETURN( dev, filp ); | 717 | LOCK_TEST_WITH_RETURN(dev, filp); |
716 | 718 | ||
717 | if ( !dev_priv ) { | 719 | if (!dev_priv) { |
718 | DRM_DEBUG( "%s called before init done\n", __FUNCTION__ ); | 720 | DRM_DEBUG("%s called before init done\n", __FUNCTION__); |
719 | return DRM_ERR(EINVAL); | 721 | return DRM_ERR(EINVAL); |
720 | } | 722 | } |
721 | 723 | ||
722 | r128_do_cce_reset( dev_priv ); | 724 | r128_do_cce_reset(dev_priv); |
723 | 725 | ||
724 | /* The CCE is no longer running after an engine reset */ | 726 | /* The CCE is no longer running after an engine reset */ |
725 | dev_priv->cce_running = 0; | 727 | dev_priv->cce_running = 0; |
@@ -727,37 +729,36 @@ int r128_cce_reset( DRM_IOCTL_ARGS ) | |||
727 | return 0; | 729 | return 0; |
728 | } | 730 | } |
729 | 731 | ||
730 | int r128_cce_idle( DRM_IOCTL_ARGS ) | 732 | int r128_cce_idle(DRM_IOCTL_ARGS) |
731 | { | 733 | { |
732 | DRM_DEVICE; | 734 | DRM_DEVICE; |
733 | drm_r128_private_t *dev_priv = dev->dev_private; | 735 | drm_r128_private_t *dev_priv = dev->dev_private; |
734 | DRM_DEBUG( "\n" ); | 736 | DRM_DEBUG("\n"); |
735 | 737 | ||
736 | LOCK_TEST_WITH_RETURN( dev, filp ); | 738 | LOCK_TEST_WITH_RETURN(dev, filp); |
737 | 739 | ||
738 | if ( dev_priv->cce_running ) { | 740 | if (dev_priv->cce_running) { |
739 | r128_do_cce_flush( dev_priv ); | 741 | r128_do_cce_flush(dev_priv); |
740 | } | 742 | } |
741 | 743 | ||
742 | return r128_do_cce_idle( dev_priv ); | 744 | return r128_do_cce_idle(dev_priv); |
743 | } | 745 | } |
744 | 746 | ||
745 | int r128_engine_reset( DRM_IOCTL_ARGS ) | 747 | int r128_engine_reset(DRM_IOCTL_ARGS) |
746 | { | 748 | { |
747 | DRM_DEVICE; | 749 | DRM_DEVICE; |
748 | DRM_DEBUG( "\n" ); | 750 | DRM_DEBUG("\n"); |
749 | 751 | ||
750 | LOCK_TEST_WITH_RETURN( dev, filp ); | 752 | LOCK_TEST_WITH_RETURN(dev, filp); |
751 | 753 | ||
752 | return r128_do_engine_reset( dev ); | 754 | return r128_do_engine_reset(dev); |
753 | } | 755 | } |
754 | 756 | ||
755 | int r128_fullscreen( DRM_IOCTL_ARGS ) | 757 | int r128_fullscreen(DRM_IOCTL_ARGS) |
756 | { | 758 | { |
757 | return DRM_ERR(EINVAL); | 759 | return DRM_ERR(EINVAL); |
758 | } | 760 | } |
759 | 761 | ||
760 | |||
761 | /* ================================================================ | 762 | /* ================================================================ |
762 | * Freelist management | 763 | * Freelist management |
763 | */ | 764 | */ |
@@ -765,7 +766,7 @@ int r128_fullscreen( DRM_IOCTL_ARGS ) | |||
765 | #define R128_BUFFER_FREE 0 | 766 | #define R128_BUFFER_FREE 0 |
766 | 767 | ||
767 | #if 0 | 768 | #if 0 |
768 | static int r128_freelist_init( drm_device_t *dev ) | 769 | static int r128_freelist_init(drm_device_t * dev) |
769 | { | 770 | { |
770 | drm_device_dma_t *dma = dev->dma; | 771 | drm_device_dma_t *dma = dev->dma; |
771 | drm_r128_private_t *dev_priv = dev->dev_private; | 772 | drm_r128_private_t *dev_priv = dev->dev_private; |
@@ -774,27 +775,26 @@ static int r128_freelist_init( drm_device_t *dev ) | |||
774 | drm_r128_freelist_t *entry; | 775 | drm_r128_freelist_t *entry; |
775 | int i; | 776 | int i; |
776 | 777 | ||
777 | dev_priv->head = drm_alloc( sizeof(drm_r128_freelist_t), | 778 | dev_priv->head = drm_alloc(sizeof(drm_r128_freelist_t), DRM_MEM_DRIVER); |
778 | DRM_MEM_DRIVER ); | 779 | if (dev_priv->head == NULL) |
779 | if ( dev_priv->head == NULL ) | ||
780 | return DRM_ERR(ENOMEM); | 780 | return DRM_ERR(ENOMEM); |
781 | 781 | ||
782 | memset( dev_priv->head, 0, sizeof(drm_r128_freelist_t) ); | 782 | memset(dev_priv->head, 0, sizeof(drm_r128_freelist_t)); |
783 | dev_priv->head->age = R128_BUFFER_USED; | 783 | dev_priv->head->age = R128_BUFFER_USED; |
784 | 784 | ||
785 | for ( i = 0 ; i < dma->buf_count ; i++ ) { | 785 | for (i = 0; i < dma->buf_count; i++) { |
786 | buf = dma->buflist[i]; | 786 | buf = dma->buflist[i]; |
787 | buf_priv = buf->dev_private; | 787 | buf_priv = buf->dev_private; |
788 | 788 | ||
789 | entry = drm_alloc( sizeof(drm_r128_freelist_t), | 789 | entry = drm_alloc(sizeof(drm_r128_freelist_t), DRM_MEM_DRIVER); |
790 | DRM_MEM_DRIVER ); | 790 | if (!entry) |
791 | if ( !entry ) return DRM_ERR(ENOMEM); | 791 | return DRM_ERR(ENOMEM); |
792 | 792 | ||
793 | entry->age = R128_BUFFER_FREE; | 793 | entry->age = R128_BUFFER_FREE; |
794 | entry->buf = buf; | 794 | entry->buf = buf; |
795 | entry->prev = dev_priv->head; | 795 | entry->prev = dev_priv->head; |
796 | entry->next = dev_priv->head->next; | 796 | entry->next = dev_priv->head->next; |
797 | if ( !entry->next ) | 797 | if (!entry->next) |
798 | dev_priv->tail = entry; | 798 | dev_priv->tail = entry; |
799 | 799 | ||
800 | buf_priv->discard = 0; | 800 | buf_priv->discard = 0; |
@@ -803,7 +803,7 @@ static int r128_freelist_init( drm_device_t *dev ) | |||
803 | 803 | ||
804 | dev_priv->head->next = entry; | 804 | dev_priv->head->next = entry; |
805 | 805 | ||
806 | if ( dev_priv->head->next ) | 806 | if (dev_priv->head->next) |
807 | dev_priv->head->next->prev = entry; | 807 | dev_priv->head->next->prev = entry; |
808 | } | 808 | } |
809 | 809 | ||
@@ -812,7 +812,7 @@ static int r128_freelist_init( drm_device_t *dev ) | |||
812 | } | 812 | } |
813 | #endif | 813 | #endif |
814 | 814 | ||
815 | static drm_buf_t *r128_freelist_get( drm_device_t *dev ) | 815 | static drm_buf_t *r128_freelist_get(drm_device_t * dev) |
816 | { | 816 | { |
817 | drm_device_dma_t *dma = dev->dma; | 817 | drm_device_dma_t *dma = dev->dma; |
818 | drm_r128_private_t *dev_priv = dev->dev_private; | 818 | drm_r128_private_t *dev_priv = dev->dev_private; |
@@ -822,20 +822,20 @@ static drm_buf_t *r128_freelist_get( drm_device_t *dev ) | |||
822 | 822 | ||
823 | /* FIXME: Optimize -- use freelist code */ | 823 | /* FIXME: Optimize -- use freelist code */ |
824 | 824 | ||
825 | for ( i = 0 ; i < dma->buf_count ; i++ ) { | 825 | for (i = 0; i < dma->buf_count; i++) { |
826 | buf = dma->buflist[i]; | 826 | buf = dma->buflist[i]; |
827 | buf_priv = buf->dev_private; | 827 | buf_priv = buf->dev_private; |
828 | if ( buf->filp == 0 ) | 828 | if (buf->filp == 0) |
829 | return buf; | 829 | return buf; |
830 | } | 830 | } |
831 | 831 | ||
832 | for ( t = 0 ; t < dev_priv->usec_timeout ; t++ ) { | 832 | for (t = 0; t < dev_priv->usec_timeout; t++) { |
833 | u32 done_age = R128_READ( R128_LAST_DISPATCH_REG ); | 833 | u32 done_age = R128_READ(R128_LAST_DISPATCH_REG); |
834 | 834 | ||
835 | for ( i = 0 ; i < dma->buf_count ; i++ ) { | 835 | for (i = 0; i < dma->buf_count; i++) { |
836 | buf = dma->buflist[i]; | 836 | buf = dma->buflist[i]; |
837 | buf_priv = buf->dev_private; | 837 | buf_priv = buf->dev_private; |
838 | if ( buf->pending && buf_priv->age <= done_age ) { | 838 | if (buf->pending && buf_priv->age <= done_age) { |
839 | /* The buffer has been processed, so it | 839 | /* The buffer has been processed, so it |
840 | * can now be used. | 840 | * can now be used. |
841 | */ | 841 | */ |
@@ -843,63 +843,63 @@ static drm_buf_t *r128_freelist_get( drm_device_t *dev ) | |||
843 | return buf; | 843 | return buf; |
844 | } | 844 | } |
845 | } | 845 | } |
846 | DRM_UDELAY( 1 ); | 846 | DRM_UDELAY(1); |
847 | } | 847 | } |
848 | 848 | ||
849 | DRM_DEBUG( "returning NULL!\n" ); | 849 | DRM_DEBUG("returning NULL!\n"); |
850 | return NULL; | 850 | return NULL; |
851 | } | 851 | } |
852 | 852 | ||
853 | void r128_freelist_reset( drm_device_t *dev ) | 853 | void r128_freelist_reset(drm_device_t * dev) |
854 | { | 854 | { |
855 | drm_device_dma_t *dma = dev->dma; | 855 | drm_device_dma_t *dma = dev->dma; |
856 | int i; | 856 | int i; |
857 | 857 | ||
858 | for ( i = 0 ; i < dma->buf_count ; i++ ) { | 858 | for (i = 0; i < dma->buf_count; i++) { |
859 | drm_buf_t *buf = dma->buflist[i]; | 859 | drm_buf_t *buf = dma->buflist[i]; |
860 | drm_r128_buf_priv_t *buf_priv = buf->dev_private; | 860 | drm_r128_buf_priv_t *buf_priv = buf->dev_private; |
861 | buf_priv->age = 0; | 861 | buf_priv->age = 0; |
862 | } | 862 | } |
863 | } | 863 | } |
864 | 864 | ||
865 | |||
866 | /* ================================================================ | 865 | /* ================================================================ |
867 | * CCE command submission | 866 | * CCE command submission |
868 | */ | 867 | */ |
869 | 868 | ||
870 | int r128_wait_ring( drm_r128_private_t *dev_priv, int n ) | 869 | int r128_wait_ring(drm_r128_private_t * dev_priv, int n) |
871 | { | 870 | { |
872 | drm_r128_ring_buffer_t *ring = &dev_priv->ring; | 871 | drm_r128_ring_buffer_t *ring = &dev_priv->ring; |
873 | int i; | 872 | int i; |
874 | 873 | ||
875 | for ( i = 0 ; i < dev_priv->usec_timeout ; i++ ) { | 874 | for (i = 0; i < dev_priv->usec_timeout; i++) { |
876 | r128_update_ring_snapshot( dev_priv ); | 875 | r128_update_ring_snapshot(dev_priv); |
877 | if ( ring->space >= n ) | 876 | if (ring->space >= n) |
878 | return 0; | 877 | return 0; |
879 | DRM_UDELAY( 1 ); | 878 | DRM_UDELAY(1); |
880 | } | 879 | } |
881 | 880 | ||
882 | /* FIXME: This is being ignored... */ | 881 | /* FIXME: This is being ignored... */ |
883 | DRM_ERROR( "failed!\n" ); | 882 | DRM_ERROR("failed!\n"); |
884 | return DRM_ERR(EBUSY); | 883 | return DRM_ERR(EBUSY); |
885 | } | 884 | } |
886 | 885 | ||
887 | static int r128_cce_get_buffers( DRMFILE filp, drm_device_t *dev, drm_dma_t *d ) | 886 | static int r128_cce_get_buffers(DRMFILE filp, drm_device_t * dev, drm_dma_t * d) |
888 | { | 887 | { |
889 | int i; | 888 | int i; |
890 | drm_buf_t *buf; | 889 | drm_buf_t *buf; |
891 | 890 | ||
892 | for ( i = d->granted_count ; i < d->request_count ; i++ ) { | 891 | for (i = d->granted_count; i < d->request_count; i++) { |
893 | buf = r128_freelist_get( dev ); | 892 | buf = r128_freelist_get(dev); |
894 | if ( !buf ) return DRM_ERR(EAGAIN); | 893 | if (!buf) |
894 | return DRM_ERR(EAGAIN); | ||
895 | 895 | ||
896 | buf->filp = filp; | 896 | buf->filp = filp; |
897 | 897 | ||
898 | if ( DRM_COPY_TO_USER( &d->request_indices[i], &buf->idx, | 898 | if (DRM_COPY_TO_USER(&d->request_indices[i], &buf->idx, |
899 | sizeof(buf->idx) ) ) | 899 | sizeof(buf->idx))) |
900 | return DRM_ERR(EFAULT); | 900 | return DRM_ERR(EFAULT); |
901 | if ( DRM_COPY_TO_USER( &d->request_sizes[i], &buf->total, | 901 | if (DRM_COPY_TO_USER(&d->request_sizes[i], &buf->total, |
902 | sizeof(buf->total) ) ) | 902 | sizeof(buf->total))) |
903 | return DRM_ERR(EFAULT); | 903 | return DRM_ERR(EFAULT); |
904 | 904 | ||
905 | d->granted_count++; | 905 | d->granted_count++; |
@@ -907,7 +907,7 @@ static int r128_cce_get_buffers( DRMFILE filp, drm_device_t *dev, drm_dma_t *d ) | |||
907 | return 0; | 907 | return 0; |
908 | } | 908 | } |
909 | 909 | ||
910 | int r128_cce_buffers( DRM_IOCTL_ARGS ) | 910 | int r128_cce_buffers(DRM_IOCTL_ARGS) |
911 | { | 911 | { |
912 | DRM_DEVICE; | 912 | DRM_DEVICE; |
913 | drm_device_dma_t *dma = dev->dma; | 913 | drm_device_dma_t *dma = dev->dma; |
@@ -915,33 +915,33 @@ int r128_cce_buffers( DRM_IOCTL_ARGS ) | |||
915 | drm_dma_t __user *argp = (void __user *)data; | 915 | drm_dma_t __user *argp = (void __user *)data; |
916 | drm_dma_t d; | 916 | drm_dma_t d; |
917 | 917 | ||
918 | LOCK_TEST_WITH_RETURN( dev, filp ); | 918 | LOCK_TEST_WITH_RETURN(dev, filp); |
919 | 919 | ||
920 | DRM_COPY_FROM_USER_IOCTL( d, argp, sizeof(d) ); | 920 | DRM_COPY_FROM_USER_IOCTL(d, argp, sizeof(d)); |
921 | 921 | ||
922 | /* Please don't send us buffers. | 922 | /* Please don't send us buffers. |
923 | */ | 923 | */ |
924 | if ( d.send_count != 0 ) { | 924 | if (d.send_count != 0) { |
925 | DRM_ERROR( "Process %d trying to send %d buffers via drmDMA\n", | 925 | DRM_ERROR("Process %d trying to send %d buffers via drmDMA\n", |
926 | DRM_CURRENTPID, d.send_count ); | 926 | DRM_CURRENTPID, d.send_count); |
927 | return DRM_ERR(EINVAL); | 927 | return DRM_ERR(EINVAL); |
928 | } | 928 | } |
929 | 929 | ||
930 | /* We'll send you buffers. | 930 | /* We'll send you buffers. |
931 | */ | 931 | */ |
932 | if ( d.request_count < 0 || d.request_count > dma->buf_count ) { | 932 | if (d.request_count < 0 || d.request_count > dma->buf_count) { |
933 | DRM_ERROR( "Process %d trying to get %d buffers (of %d max)\n", | 933 | DRM_ERROR("Process %d trying to get %d buffers (of %d max)\n", |
934 | DRM_CURRENTPID, d.request_count, dma->buf_count ); | 934 | DRM_CURRENTPID, d.request_count, dma->buf_count); |
935 | return DRM_ERR(EINVAL); | 935 | return DRM_ERR(EINVAL); |
936 | } | 936 | } |
937 | 937 | ||
938 | d.granted_count = 0; | 938 | d.granted_count = 0; |
939 | 939 | ||
940 | if ( d.request_count ) { | 940 | if (d.request_count) { |
941 | ret = r128_cce_get_buffers( filp, dev, &d ); | 941 | ret = r128_cce_get_buffers(filp, dev, &d); |
942 | } | 942 | } |
943 | 943 | ||
944 | DRM_COPY_TO_USER_IOCTL(argp, d, sizeof(d) ); | 944 | DRM_COPY_TO_USER_IOCTL(argp, d, sizeof(d)); |
945 | 945 | ||
946 | return ret; | 946 | return ret; |
947 | } | 947 | } |