aboutsummaryrefslogtreecommitdiffstats
path: root/drivers/char/drm/ffb_context.c
diff options
context:
space:
mode:
Diffstat (limited to 'drivers/char/drm/ffb_context.c')
-rw-r--r--drivers/char/drm/ffb_context.c230
1 files changed, 113 insertions, 117 deletions
diff --git a/drivers/char/drm/ffb_context.c b/drivers/char/drm/ffb_context.c
index f51812078010..8a6cc2751bc9 100644
--- a/drivers/char/drm/ffb_context.c
+++ b/drivers/char/drm/ffb_context.c
@@ -15,8 +15,7 @@
15 15
16#include "ffb_drv.h" 16#include "ffb_drv.h"
17 17
18static int DRM(alloc_queue)(drm_device_t *dev, int is_2d_only) 18static int DRM(alloc_queue) (drm_device_t * dev, int is_2d_only) {
19{
20 ffb_dev_priv_t *fpriv = (ffb_dev_priv_t *) dev->dev_private; 19 ffb_dev_priv_t *fpriv = (ffb_dev_priv_t *) dev->dev_private;
21 int i; 20 int i;
22 21
@@ -37,7 +36,7 @@ static int DRM(alloc_queue)(drm_device_t *dev, int is_2d_only)
37 return i + 1; 36 return i + 1;
38} 37}
39 38
40static void ffb_save_context(ffb_dev_priv_t *fpriv, int idx) 39static void ffb_save_context(ffb_dev_priv_t * fpriv, int idx)
41{ 40{
42 ffb_fbcPtr ffb = fpriv->regs; 41 ffb_fbcPtr ffb = fpriv->regs;
43 struct ffb_hw_context *ctx; 42 struct ffb_hw_context *ctx;
@@ -94,36 +93,36 @@ static void ffb_save_context(ffb_dev_priv_t *fpriv, int idx)
94 93
95 /* Capture rendering attributes. */ 94 /* Capture rendering attributes. */
96 95
97 ctx->ppc = upa_readl(&ffb->ppc); /* Pixel Processor Control */ 96 ctx->ppc = upa_readl(&ffb->ppc); /* Pixel Processor Control */
98 ctx->wid = upa_readl(&ffb->wid); /* Current WID */ 97 ctx->wid = upa_readl(&ffb->wid); /* Current WID */
99 ctx->fg = upa_readl(&ffb->fg); /* Constant FG color */ 98 ctx->fg = upa_readl(&ffb->fg); /* Constant FG color */
100 ctx->bg = upa_readl(&ffb->bg); /* Constant BG color */ 99 ctx->bg = upa_readl(&ffb->bg); /* Constant BG color */
101 ctx->consty = upa_readl(&ffb->consty); /* Constant Y */ 100 ctx->consty = upa_readl(&ffb->consty); /* Constant Y */
102 ctx->constz = upa_readl(&ffb->constz); /* Constant Z */ 101 ctx->constz = upa_readl(&ffb->constz); /* Constant Z */
103 ctx->xclip = upa_readl(&ffb->xclip); /* X plane clip */ 102 ctx->xclip = upa_readl(&ffb->xclip); /* X plane clip */
104 ctx->dcss = upa_readl(&ffb->dcss); /* Depth Cue Scale Slope */ 103 ctx->dcss = upa_readl(&ffb->dcss); /* Depth Cue Scale Slope */
105 ctx->vclipmin = upa_readl(&ffb->vclipmin); /* Primary XY clip, minimum */ 104 ctx->vclipmin = upa_readl(&ffb->vclipmin); /* Primary XY clip, minimum */
106 ctx->vclipmax = upa_readl(&ffb->vclipmax); /* Primary XY clip, maximum */ 105 ctx->vclipmax = upa_readl(&ffb->vclipmax); /* Primary XY clip, maximum */
107 ctx->vclipzmin = upa_readl(&ffb->vclipzmin); /* Primary Z clip, minimum */ 106 ctx->vclipzmin = upa_readl(&ffb->vclipzmin); /* Primary Z clip, minimum */
108 ctx->vclipzmax = upa_readl(&ffb->vclipzmax); /* Primary Z clip, maximum */ 107 ctx->vclipzmax = upa_readl(&ffb->vclipzmax); /* Primary Z clip, maximum */
109 ctx->dcsf = upa_readl(&ffb->dcsf); /* Depth Cue Scale Front Bound */ 108 ctx->dcsf = upa_readl(&ffb->dcsf); /* Depth Cue Scale Front Bound */
110 ctx->dcsb = upa_readl(&ffb->dcsb); /* Depth Cue Scale Back Bound */ 109 ctx->dcsb = upa_readl(&ffb->dcsb); /* Depth Cue Scale Back Bound */
111 ctx->dczf = upa_readl(&ffb->dczf); /* Depth Cue Scale Z Front */ 110 ctx->dczf = upa_readl(&ffb->dczf); /* Depth Cue Scale Z Front */
112 ctx->dczb = upa_readl(&ffb->dczb); /* Depth Cue Scale Z Back */ 111 ctx->dczb = upa_readl(&ffb->dczb); /* Depth Cue Scale Z Back */
113 ctx->blendc = upa_readl(&ffb->blendc); /* Alpha Blend Control */ 112 ctx->blendc = upa_readl(&ffb->blendc); /* Alpha Blend Control */
114 ctx->blendc1 = upa_readl(&ffb->blendc1); /* Alpha Blend Color 1 */ 113 ctx->blendc1 = upa_readl(&ffb->blendc1); /* Alpha Blend Color 1 */
115 ctx->blendc2 = upa_readl(&ffb->blendc2); /* Alpha Blend Color 2 */ 114 ctx->blendc2 = upa_readl(&ffb->blendc2); /* Alpha Blend Color 2 */
116 ctx->fbc = upa_readl(&ffb->fbc); /* Frame Buffer Control */ 115 ctx->fbc = upa_readl(&ffb->fbc); /* Frame Buffer Control */
117 ctx->rop = upa_readl(&ffb->rop); /* Raster Operation */ 116 ctx->rop = upa_readl(&ffb->rop); /* Raster Operation */
118 ctx->cmp = upa_readl(&ffb->cmp); /* Compare Controls */ 117 ctx->cmp = upa_readl(&ffb->cmp); /* Compare Controls */
119 ctx->matchab = upa_readl(&ffb->matchab); /* Buffer A/B Match Ops */ 118 ctx->matchab = upa_readl(&ffb->matchab); /* Buffer A/B Match Ops */
120 ctx->matchc = upa_readl(&ffb->matchc); /* Buffer C Match Ops */ 119 ctx->matchc = upa_readl(&ffb->matchc); /* Buffer C Match Ops */
121 ctx->magnab = upa_readl(&ffb->magnab); /* Buffer A/B Magnitude Ops */ 120 ctx->magnab = upa_readl(&ffb->magnab); /* Buffer A/B Magnitude Ops */
122 ctx->magnc = upa_readl(&ffb->magnc); /* Buffer C Magnitude Ops */ 121 ctx->magnc = upa_readl(&ffb->magnc); /* Buffer C Magnitude Ops */
123 ctx->pmask = upa_readl(&ffb->pmask); /* RGB Plane Mask */ 122 ctx->pmask = upa_readl(&ffb->pmask); /* RGB Plane Mask */
124 ctx->xpmask = upa_readl(&ffb->xpmask); /* X Plane Mask */ 123 ctx->xpmask = upa_readl(&ffb->xpmask); /* X Plane Mask */
125 ctx->ypmask = upa_readl(&ffb->ypmask); /* Y Plane Mask */ 124 ctx->ypmask = upa_readl(&ffb->ypmask); /* Y Plane Mask */
126 ctx->zpmask = upa_readl(&ffb->zpmask); /* Z Plane Mask */ 125 ctx->zpmask = upa_readl(&ffb->zpmask); /* Z Plane Mask */
127 126
128 /* Auxiliary Clips. */ 127 /* Auxiliary Clips. */
129 ctx->auxclip0min = upa_readl(&ffb->auxclip[0].min); 128 ctx->auxclip0min = upa_readl(&ffb->auxclip[0].min);
@@ -135,9 +134,9 @@ static void ffb_save_context(ffb_dev_priv_t *fpriv, int idx)
135 ctx->auxclip3min = upa_readl(&ffb->auxclip[3].min); 134 ctx->auxclip3min = upa_readl(&ffb->auxclip[3].min);
136 ctx->auxclip3max = upa_readl(&ffb->auxclip[3].max); 135 ctx->auxclip3max = upa_readl(&ffb->auxclip[3].max);
137 136
138 ctx->lpat = upa_readl(&ffb->lpat); /* Line Pattern */ 137 ctx->lpat = upa_readl(&ffb->lpat); /* Line Pattern */
139 ctx->fontxy = upa_readl(&ffb->fontxy); /* XY Font Coordinate */ 138 ctx->fontxy = upa_readl(&ffb->fontxy); /* XY Font Coordinate */
140 ctx->fontw = upa_readl(&ffb->fontw); /* Font Width */ 139 ctx->fontw = upa_readl(&ffb->fontw); /* Font Width */
141 ctx->fontinc = upa_readl(&ffb->fontinc); /* Font X/Y Increment */ 140 ctx->fontinc = upa_readl(&ffb->fontinc); /* Font X/Y Increment */
142 141
143 /* These registers/features only exist on FFB2 and later chips. */ 142 /* These registers/features only exist on FFB2 and later chips. */
@@ -145,12 +144,12 @@ static void ffb_save_context(ffb_dev_priv_t *fpriv, int idx)
145 ctx->dcss1 = upa_readl(&ffb->dcss1); /* Depth Cue Scale Slope 1 */ 144 ctx->dcss1 = upa_readl(&ffb->dcss1); /* Depth Cue Scale Slope 1 */
146 ctx->dcss2 = upa_readl(&ffb->dcss2); /* Depth Cue Scale Slope 2 */ 145 ctx->dcss2 = upa_readl(&ffb->dcss2); /* Depth Cue Scale Slope 2 */
147 ctx->dcss2 = upa_readl(&ffb->dcss3); /* Depth Cue Scale Slope 3 */ 146 ctx->dcss2 = upa_readl(&ffb->dcss3); /* Depth Cue Scale Slope 3 */
148 ctx->dcs2 = upa_readl(&ffb->dcs2); /* Depth Cue Scale 2 */ 147 ctx->dcs2 = upa_readl(&ffb->dcs2); /* Depth Cue Scale 2 */
149 ctx->dcs3 = upa_readl(&ffb->dcs3); /* Depth Cue Scale 3 */ 148 ctx->dcs3 = upa_readl(&ffb->dcs3); /* Depth Cue Scale 3 */
150 ctx->dcs4 = upa_readl(&ffb->dcs4); /* Depth Cue Scale 4 */ 149 ctx->dcs4 = upa_readl(&ffb->dcs4); /* Depth Cue Scale 4 */
151 ctx->dcd2 = upa_readl(&ffb->dcd2); /* Depth Cue Depth 2 */ 150 ctx->dcd2 = upa_readl(&ffb->dcd2); /* Depth Cue Depth 2 */
152 ctx->dcd3 = upa_readl(&ffb->dcd3); /* Depth Cue Depth 3 */ 151 ctx->dcd3 = upa_readl(&ffb->dcd3); /* Depth Cue Depth 3 */
153 ctx->dcd4 = upa_readl(&ffb->dcd4); /* Depth Cue Depth 4 */ 152 ctx->dcd4 = upa_readl(&ffb->dcd4); /* Depth Cue Depth 4 */
154 153
155 /* And stencil/stencilctl only exists on FFB2+ and later 154 /* And stencil/stencilctl only exists on FFB2+ and later
156 * due to the introduction of 3DRAM-III. 155 * due to the introduction of 3DRAM-III.
@@ -170,7 +169,7 @@ static void ffb_save_context(ffb_dev_priv_t *fpriv, int idx)
170 ctx->ucsr = upa_readl(&ffb->ucsr); 169 ctx->ucsr = upa_readl(&ffb->ucsr);
171} 170}
172 171
173static void ffb_restore_context(ffb_dev_priv_t *fpriv, int old, int idx) 172static void ffb_restore_context(ffb_dev_priv_t * fpriv, int old, int idx)
174{ 173{
175 ffb_fbcPtr ffb = fpriv->regs; 174 ffb_fbcPtr ffb = fpriv->regs;
176 struct ffb_hw_context *ctx; 175 struct ffb_hw_context *ctx;
@@ -193,7 +192,7 @@ static void ffb_restore_context(ffb_dev_priv_t *fpriv, int old, int idx)
193 192
194 upa_writel(ctx->ppc, &ffb->ppc); 193 upa_writel(ctx->ppc, &ffb->ppc);
195 upa_writel(ctx->wid, &ffb->wid); 194 upa_writel(ctx->wid, &ffb->wid);
196 upa_writel(ctx->fg, &ffb->fg); 195 upa_writel(ctx->fg, &ffb->fg);
197 upa_writel(ctx->bg, &ffb->bg); 196 upa_writel(ctx->bg, &ffb->bg);
198 upa_writel(ctx->xclip, &ffb->xclip); 197 upa_writel(ctx->xclip, &ffb->xclip);
199 upa_writel(ctx->fbc, &ffb->fbc); 198 upa_writel(ctx->fbc, &ffb->fbc);
@@ -237,36 +236,36 @@ static void ffb_restore_context(ffb_dev_priv_t *fpriv, int old, int idx)
237 236
238 /* Restore rendering attributes. */ 237 /* Restore rendering attributes. */
239 238
240 upa_writel(ctx->ppc, &ffb->ppc); /* Pixel Processor Control */ 239 upa_writel(ctx->ppc, &ffb->ppc); /* Pixel Processor Control */
241 upa_writel(ctx->wid, &ffb->wid); /* Current WID */ 240 upa_writel(ctx->wid, &ffb->wid); /* Current WID */
242 upa_writel(ctx->fg, &ffb->fg); /* Constant FG color */ 241 upa_writel(ctx->fg, &ffb->fg); /* Constant FG color */
243 upa_writel(ctx->bg, &ffb->bg); /* Constant BG color */ 242 upa_writel(ctx->bg, &ffb->bg); /* Constant BG color */
244 upa_writel(ctx->consty, &ffb->consty); /* Constant Y */ 243 upa_writel(ctx->consty, &ffb->consty); /* Constant Y */
245 upa_writel(ctx->constz, &ffb->constz); /* Constant Z */ 244 upa_writel(ctx->constz, &ffb->constz); /* Constant Z */
246 upa_writel(ctx->xclip, &ffb->xclip); /* X plane clip */ 245 upa_writel(ctx->xclip, &ffb->xclip); /* X plane clip */
247 upa_writel(ctx->dcss, &ffb->dcss); /* Depth Cue Scale Slope */ 246 upa_writel(ctx->dcss, &ffb->dcss); /* Depth Cue Scale Slope */
248 upa_writel(ctx->vclipmin, &ffb->vclipmin); /* Primary XY clip, minimum */ 247 upa_writel(ctx->vclipmin, &ffb->vclipmin); /* Primary XY clip, minimum */
249 upa_writel(ctx->vclipmax, &ffb->vclipmax); /* Primary XY clip, maximum */ 248 upa_writel(ctx->vclipmax, &ffb->vclipmax); /* Primary XY clip, maximum */
250 upa_writel(ctx->vclipzmin, &ffb->vclipzmin); /* Primary Z clip, minimum */ 249 upa_writel(ctx->vclipzmin, &ffb->vclipzmin); /* Primary Z clip, minimum */
251 upa_writel(ctx->vclipzmax, &ffb->vclipzmax); /* Primary Z clip, maximum */ 250 upa_writel(ctx->vclipzmax, &ffb->vclipzmax); /* Primary Z clip, maximum */
252 upa_writel(ctx->dcsf, &ffb->dcsf); /* Depth Cue Scale Front Bound */ 251 upa_writel(ctx->dcsf, &ffb->dcsf); /* Depth Cue Scale Front Bound */
253 upa_writel(ctx->dcsb, &ffb->dcsb); /* Depth Cue Scale Back Bound */ 252 upa_writel(ctx->dcsb, &ffb->dcsb); /* Depth Cue Scale Back Bound */
254 upa_writel(ctx->dczf, &ffb->dczf); /* Depth Cue Scale Z Front */ 253 upa_writel(ctx->dczf, &ffb->dczf); /* Depth Cue Scale Z Front */
255 upa_writel(ctx->dczb, &ffb->dczb); /* Depth Cue Scale Z Back */ 254 upa_writel(ctx->dczb, &ffb->dczb); /* Depth Cue Scale Z Back */
256 upa_writel(ctx->blendc, &ffb->blendc); /* Alpha Blend Control */ 255 upa_writel(ctx->blendc, &ffb->blendc); /* Alpha Blend Control */
257 upa_writel(ctx->blendc1, &ffb->blendc1); /* Alpha Blend Color 1 */ 256 upa_writel(ctx->blendc1, &ffb->blendc1); /* Alpha Blend Color 1 */
258 upa_writel(ctx->blendc2, &ffb->blendc2); /* Alpha Blend Color 2 */ 257 upa_writel(ctx->blendc2, &ffb->blendc2); /* Alpha Blend Color 2 */
259 upa_writel(ctx->fbc, &ffb->fbc); /* Frame Buffer Control */ 258 upa_writel(ctx->fbc, &ffb->fbc); /* Frame Buffer Control */
260 upa_writel(ctx->rop, &ffb->rop); /* Raster Operation */ 259 upa_writel(ctx->rop, &ffb->rop); /* Raster Operation */
261 upa_writel(ctx->cmp, &ffb->cmp); /* Compare Controls */ 260 upa_writel(ctx->cmp, &ffb->cmp); /* Compare Controls */
262 upa_writel(ctx->matchab, &ffb->matchab); /* Buffer A/B Match Ops */ 261 upa_writel(ctx->matchab, &ffb->matchab); /* Buffer A/B Match Ops */
263 upa_writel(ctx->matchc, &ffb->matchc); /* Buffer C Match Ops */ 262 upa_writel(ctx->matchc, &ffb->matchc); /* Buffer C Match Ops */
264 upa_writel(ctx->magnab, &ffb->magnab); /* Buffer A/B Magnitude Ops */ 263 upa_writel(ctx->magnab, &ffb->magnab); /* Buffer A/B Magnitude Ops */
265 upa_writel(ctx->magnc, &ffb->magnc); /* Buffer C Magnitude Ops */ 264 upa_writel(ctx->magnc, &ffb->magnc); /* Buffer C Magnitude Ops */
266 upa_writel(ctx->pmask, &ffb->pmask); /* RGB Plane Mask */ 265 upa_writel(ctx->pmask, &ffb->pmask); /* RGB Plane Mask */
267 upa_writel(ctx->xpmask, &ffb->xpmask); /* X Plane Mask */ 266 upa_writel(ctx->xpmask, &ffb->xpmask); /* X Plane Mask */
268 upa_writel(ctx->ypmask, &ffb->ypmask); /* Y Plane Mask */ 267 upa_writel(ctx->ypmask, &ffb->ypmask); /* Y Plane Mask */
269 upa_writel(ctx->zpmask, &ffb->zpmask); /* Z Plane Mask */ 268 upa_writel(ctx->zpmask, &ffb->zpmask); /* Z Plane Mask */
270 269
271 /* Auxiliary Clips. */ 270 /* Auxiliary Clips. */
272 upa_writel(ctx->auxclip0min, &ffb->auxclip[0].min); 271 upa_writel(ctx->auxclip0min, &ffb->auxclip[0].min);
@@ -278,9 +277,9 @@ static void ffb_restore_context(ffb_dev_priv_t *fpriv, int old, int idx)
278 upa_writel(ctx->auxclip3min, &ffb->auxclip[3].min); 277 upa_writel(ctx->auxclip3min, &ffb->auxclip[3].min);
279 upa_writel(ctx->auxclip3max, &ffb->auxclip[3].max); 278 upa_writel(ctx->auxclip3max, &ffb->auxclip[3].max);
280 279
281 upa_writel(ctx->lpat, &ffb->lpat); /* Line Pattern */ 280 upa_writel(ctx->lpat, &ffb->lpat); /* Line Pattern */
282 upa_writel(ctx->fontxy, &ffb->fontxy); /* XY Font Coordinate */ 281 upa_writel(ctx->fontxy, &ffb->fontxy); /* XY Font Coordinate */
283 upa_writel(ctx->fontw, &ffb->fontw); /* Font Width */ 282 upa_writel(ctx->fontw, &ffb->fontw); /* Font Width */
284 upa_writel(ctx->fontinc, &ffb->fontinc); /* Font X/Y Increment */ 283 upa_writel(ctx->fontinc, &ffb->fontinc); /* Font X/Y Increment */
285 284
286 /* These registers/features only exist on FFB2 and later chips. */ 285 /* These registers/features only exist on FFB2 and later chips. */
@@ -354,91 +353,87 @@ static void FFBWait(ffb_fbcPtr ffb)
354 } while (--limit); 353 } while (--limit);
355} 354}
356 355
357int ffb_driver_context_switch(drm_device_t *dev, int old, int new) 356int ffb_driver_context_switch(drm_device_t * dev, int old, int new)
358{ 357{
359 ffb_dev_priv_t *fpriv = (ffb_dev_priv_t *) dev->dev_private; 358 ffb_dev_priv_t *fpriv = (ffb_dev_priv_t *) dev->dev_private;
360 359
361#ifdef DRM_DMA_HISTOGRAM 360#ifdef DRM_DMA_HISTOGRAM
362 dev->ctx_start = get_cycles(); 361 dev->ctx_start = get_cycles();
363#endif 362#endif
364
365 DRM_DEBUG("Context switch from %d to %d\n", old, new);
366 363
367 if (new == dev->last_context || 364 DRM_DEBUG("Context switch from %d to %d\n", old, new);
368 dev->last_context == 0) { 365
366 if (new == dev->last_context || dev->last_context == 0) {
369 dev->last_context = new; 367 dev->last_context = new;
370 return 0; 368 return 0;
371 } 369 }
372 370
373 FFBWait(fpriv->regs); 371 FFBWait(fpriv->regs);
374 ffb_save_context(fpriv, old); 372 ffb_save_context(fpriv, old);
375 ffb_restore_context(fpriv, old, new); 373 ffb_restore_context(fpriv, old, new);
376 FFBWait(fpriv->regs); 374 FFBWait(fpriv->regs);
377 375
378 dev->last_context = new; 376 dev->last_context = new;
379 377
380 return 0; 378 return 0;
381} 379}
382 380
383int ffb_driver_resctx(struct inode *inode, struct file *filp, unsigned int cmd, 381int ffb_driver_resctx(struct inode *inode, struct file *filp, unsigned int cmd,
384 unsigned long arg) 382 unsigned long arg)
385{ 383{
386 drm_ctx_res_t res; 384 drm_ctx_res_t res;
387 drm_ctx_t ctx; 385 drm_ctx_t ctx;
388 int i; 386 int i;
389 387
390 DRM_DEBUG("%d\n", DRM_RESERVED_CONTEXTS); 388 DRM_DEBUG("%d\n", DRM_RESERVED_CONTEXTS);
391 if (copy_from_user(&res, (drm_ctx_res_t __user *)arg, sizeof(res))) 389 if (copy_from_user(&res, (drm_ctx_res_t __user *) arg, sizeof(res)))
392 return -EFAULT; 390 return -EFAULT;
393 if (res.count >= DRM_RESERVED_CONTEXTS) { 391 if (res.count >= DRM_RESERVED_CONTEXTS) {
394 memset(&ctx, 0, sizeof(ctx)); 392 memset(&ctx, 0, sizeof(ctx));
395 for (i = 0; i < DRM_RESERVED_CONTEXTS; i++) { 393 for (i = 0; i < DRM_RESERVED_CONTEXTS; i++) {
396 ctx.handle = i; 394 ctx.handle = i;
397 if (copy_to_user(&res.contexts[i], 395 if (copy_to_user(&res.contexts[i], &i, sizeof(i)))
398 &i,
399 sizeof(i)))
400 return -EFAULT; 396 return -EFAULT;
401 } 397 }
402 } 398 }
403 res.count = DRM_RESERVED_CONTEXTS; 399 res.count = DRM_RESERVED_CONTEXTS;
404 if (copy_to_user((drm_ctx_res_t __user *)arg, &res, sizeof(res))) 400 if (copy_to_user((drm_ctx_res_t __user *) arg, &res, sizeof(res)))
405 return -EFAULT; 401 return -EFAULT;
406 return 0; 402 return 0;
407} 403}
408 404
409
410int ffb_driver_addctx(struct inode *inode, struct file *filp, unsigned int cmd, 405int ffb_driver_addctx(struct inode *inode, struct file *filp, unsigned int cmd,
411 unsigned long arg) 406 unsigned long arg)
412{ 407{
413 drm_file_t *priv = filp->private_data; 408 drm_file_t *priv = filp->private_data;
414 drm_device_t *dev = priv->dev; 409 drm_device_t *dev = priv->dev;
415 drm_ctx_t ctx; 410 drm_ctx_t ctx;
416 int idx; 411 int idx;
417 412
418 if (copy_from_user(&ctx, (drm_ctx_t __user *)arg, sizeof(ctx))) 413 if (copy_from_user(&ctx, (drm_ctx_t __user *) arg, sizeof(ctx)))
419 return -EFAULT; 414 return -EFAULT;
420 idx = DRM(alloc_queue)(dev, (ctx.flags & _DRM_CONTEXT_2DONLY)); 415 idx = DRM(alloc_queue) (dev, (ctx.flags & _DRM_CONTEXT_2DONLY));
421 if (idx < 0) 416 if (idx < 0)
422 return -ENFILE; 417 return -ENFILE;
423 418
424 DRM_DEBUG("%d\n", ctx.handle); 419 DRM_DEBUG("%d\n", ctx.handle);
425 ctx.handle = idx; 420 ctx.handle = idx;
426 if (copy_to_user((drm_ctx_t __user *)arg, &ctx, sizeof(ctx))) 421 if (copy_to_user((drm_ctx_t __user *) arg, &ctx, sizeof(ctx)))
427 return -EFAULT; 422 return -EFAULT;
428 return 0; 423 return 0;
429} 424}
430 425
431int ffb_driver_modctx(struct inode *inode, struct file *filp, unsigned int cmd, 426int ffb_driver_modctx(struct inode *inode, struct file *filp, unsigned int cmd,
432 unsigned long arg) 427 unsigned long arg)
433{ 428{
434 drm_file_t *priv = filp->private_data; 429 drm_file_t *priv = filp->private_data;
435 drm_device_t *dev = priv->dev; 430 drm_device_t *dev = priv->dev;
436 ffb_dev_priv_t *fpriv = (ffb_dev_priv_t *) dev->dev_private; 431 ffb_dev_priv_t *fpriv = (ffb_dev_priv_t *) dev->dev_private;
437 struct ffb_hw_context *hwctx; 432 struct ffb_hw_context *hwctx;
438 drm_ctx_t ctx; 433 drm_ctx_t ctx;
439 int idx; 434 int idx;
440 435
441 if (copy_from_user(&ctx, (drm_ctx_t __user *)arg, sizeof(ctx))) 436 if (copy_from_user(&ctx, (drm_ctx_t __user *) arg, sizeof(ctx)))
442 return -EFAULT; 437 return -EFAULT;
443 438
444 idx = ctx.handle; 439 idx = ctx.handle;
@@ -458,16 +453,16 @@ int ffb_driver_modctx(struct inode *inode, struct file *filp, unsigned int cmd,
458} 453}
459 454
460int ffb_driver_getctx(struct inode *inode, struct file *filp, unsigned int cmd, 455int ffb_driver_getctx(struct inode *inode, struct file *filp, unsigned int cmd,
461 unsigned long arg) 456 unsigned long arg)
462{ 457{
463 drm_file_t *priv = filp->private_data; 458 drm_file_t *priv = filp->private_data;
464 drm_device_t *dev = priv->dev; 459 drm_device_t *dev = priv->dev;
465 ffb_dev_priv_t *fpriv = (ffb_dev_priv_t *) dev->dev_private; 460 ffb_dev_priv_t *fpriv = (ffb_dev_priv_t *) dev->dev_private;
466 struct ffb_hw_context *hwctx; 461 struct ffb_hw_context *hwctx;
467 drm_ctx_t ctx; 462 drm_ctx_t ctx;
468 int idx; 463 int idx;
469 464
470 if (copy_from_user(&ctx, (drm_ctx_t __user *)arg, sizeof(ctx))) 465 if (copy_from_user(&ctx, (drm_ctx_t __user *) arg, sizeof(ctx)))
471 return -EFAULT; 466 return -EFAULT;
472 467
473 idx = ctx.handle; 468 idx = ctx.handle;
@@ -483,31 +478,31 @@ int ffb_driver_getctx(struct inode *inode, struct file *filp, unsigned int cmd,
483 else 478 else
484 ctx.flags = 0; 479 ctx.flags = 0;
485 480
486 if (copy_to_user((drm_ctx_t __user *)arg, &ctx, sizeof(ctx))) 481 if (copy_to_user((drm_ctx_t __user *) arg, &ctx, sizeof(ctx)))
487 return -EFAULT; 482 return -EFAULT;
488 483
489 return 0; 484 return 0;
490} 485}
491 486
492int ffb_driver_switchctx(struct inode *inode, struct file *filp, unsigned int cmd, 487int ffb_driver_switchctx(struct inode *inode, struct file *filp,
493 unsigned long arg) 488 unsigned int cmd, unsigned long arg)
494{ 489{
495 drm_file_t *priv = filp->private_data; 490 drm_file_t *priv = filp->private_data;
496 drm_device_t *dev = priv->dev; 491 drm_device_t *dev = priv->dev;
497 drm_ctx_t ctx; 492 drm_ctx_t ctx;
498 493
499 if (copy_from_user(&ctx, (drm_ctx_t __user *)arg, sizeof(ctx))) 494 if (copy_from_user(&ctx, (drm_ctx_t __user *) arg, sizeof(ctx)))
500 return -EFAULT; 495 return -EFAULT;
501 DRM_DEBUG("%d\n", ctx.handle); 496 DRM_DEBUG("%d\n", ctx.handle);
502 return ffb_driver_context_switch(dev, dev->last_context, ctx.handle); 497 return ffb_driver_context_switch(dev, dev->last_context, ctx.handle);
503} 498}
504 499
505int ffb_driver_newctx(struct inode *inode, struct file *filp, unsigned int cmd, 500int ffb_driver_newctx(struct inode *inode, struct file *filp, unsigned int cmd,
506 unsigned long arg) 501 unsigned long arg)
507{ 502{
508 drm_ctx_t ctx; 503 drm_ctx_t ctx;
509 504
510 if (copy_from_user(&ctx, (drm_ctx_t __user *)arg, sizeof(ctx))) 505 if (copy_from_user(&ctx, (drm_ctx_t __user *) arg, sizeof(ctx)))
511 return -EFAULT; 506 return -EFAULT;
512 DRM_DEBUG("%d\n", ctx.handle); 507 DRM_DEBUG("%d\n", ctx.handle);
513 508
@@ -515,15 +510,15 @@ int ffb_driver_newctx(struct inode *inode, struct file *filp, unsigned int cmd,
515} 510}
516 511
517int ffb_driver_rmctx(struct inode *inode, struct file *filp, unsigned int cmd, 512int ffb_driver_rmctx(struct inode *inode, struct file *filp, unsigned int cmd,
518 unsigned long arg) 513 unsigned long arg)
519{ 514{
520 drm_ctx_t ctx; 515 drm_ctx_t ctx;
521 drm_file_t *priv = filp->private_data; 516 drm_file_t *priv = filp->private_data;
522 drm_device_t *dev = priv->dev; 517 drm_device_t *dev = priv->dev;
523 ffb_dev_priv_t *fpriv = (ffb_dev_priv_t *) dev->dev_private; 518 ffb_dev_priv_t *fpriv = (ffb_dev_priv_t *) dev->dev_private;
524 int idx; 519 int idx;
525 520
526 if (copy_from_user(&ctx, (drm_ctx_t __user *)arg, sizeof(ctx))) 521 if (copy_from_user(&ctx, (drm_ctx_t __user *) arg, sizeof(ctx)))
527 return -EFAULT; 522 return -EFAULT;
528 DRM_DEBUG("%d\n", ctx.handle); 523 DRM_DEBUG("%d\n", ctx.handle);
529 524
@@ -544,7 +539,8 @@ void ffb_set_context_ioctls(void)
544 DRM(ioctls)[DRM_IOCTL_NR(DRM_IOCTL_RM_CTX)].func = ffb_driver_rmctx; 539 DRM(ioctls)[DRM_IOCTL_NR(DRM_IOCTL_RM_CTX)].func = ffb_driver_rmctx;
545 DRM(ioctls)[DRM_IOCTL_NR(DRM_IOCTL_MOD_CTX)].func = ffb_driver_modctx; 540 DRM(ioctls)[DRM_IOCTL_NR(DRM_IOCTL_MOD_CTX)].func = ffb_driver_modctx;
546 DRM(ioctls)[DRM_IOCTL_NR(DRM_IOCTL_GET_CTX)].func = ffb_driver_getctx; 541 DRM(ioctls)[DRM_IOCTL_NR(DRM_IOCTL_GET_CTX)].func = ffb_driver_getctx;
547 DRM(ioctls)[DRM_IOCTL_NR(DRM_IOCTL_SWITCH_CTX)].func = ffb_driver_switchctx; 542 DRM(ioctls)[DRM_IOCTL_NR(DRM_IOCTL_SWITCH_CTX)].func =
543 ffb_driver_switchctx;
548 DRM(ioctls)[DRM_IOCTL_NR(DRM_IOCTL_NEW_CTX)].func = ffb_driver_newctx; 544 DRM(ioctls)[DRM_IOCTL_NR(DRM_IOCTL_NEW_CTX)].func = ffb_driver_newctx;
549 DRM(ioctls)[DRM_IOCTL_NR(DRM_IOCTL_RES_CTX)].func = ffb_driver_resctx; 545 DRM(ioctls)[DRM_IOCTL_NR(DRM_IOCTL_RES_CTX)].func = ffb_driver_resctx;
550 546