diff options
Diffstat (limited to 'drivers/char/drm/i830_dma.c')
-rw-r--r-- | drivers/char/drm/i830_dma.c | 210 |
1 files changed, 82 insertions, 128 deletions
diff --git a/drivers/char/drm/i830_dma.c b/drivers/char/drm/i830_dma.c index dc20c1a7834e..43a1f78712d6 100644 --- a/drivers/char/drm/i830_dma.c +++ b/drivers/char/drm/i830_dma.c | |||
@@ -122,10 +122,9 @@ static const struct file_operations i830_buffer_fops = { | |||
122 | .fasync = drm_fasync, | 122 | .fasync = drm_fasync, |
123 | }; | 123 | }; |
124 | 124 | ||
125 | static int i830_map_buffer(struct drm_buf * buf, struct file *filp) | 125 | static int i830_map_buffer(struct drm_buf * buf, struct drm_file *file_priv) |
126 | { | 126 | { |
127 | struct drm_file *priv = filp->private_data; | 127 | struct drm_device *dev = file_priv->head->dev; |
128 | struct drm_device *dev = priv->head->dev; | ||
129 | drm_i830_buf_priv_t *buf_priv = buf->dev_private; | 128 | drm_i830_buf_priv_t *buf_priv = buf->dev_private; |
130 | drm_i830_private_t *dev_priv = dev->dev_private; | 129 | drm_i830_private_t *dev_priv = dev->dev_private; |
131 | const struct file_operations *old_fops; | 130 | const struct file_operations *old_fops; |
@@ -136,13 +135,13 @@ static int i830_map_buffer(struct drm_buf * buf, struct file *filp) | |||
136 | return -EINVAL; | 135 | return -EINVAL; |
137 | 136 | ||
138 | down_write(¤t->mm->mmap_sem); | 137 | down_write(¤t->mm->mmap_sem); |
139 | old_fops = filp->f_op; | 138 | old_fops = file_priv->filp->f_op; |
140 | filp->f_op = &i830_buffer_fops; | 139 | file_priv->filp->f_op = &i830_buffer_fops; |
141 | dev_priv->mmap_buffer = buf; | 140 | dev_priv->mmap_buffer = buf; |
142 | virtual = do_mmap(filp, 0, buf->total, PROT_READ | PROT_WRITE, | 141 | virtual = do_mmap(file_priv->filp, 0, buf->total, PROT_READ | PROT_WRITE, |
143 | MAP_SHARED, buf->bus_address); | 142 | MAP_SHARED, buf->bus_address); |
144 | dev_priv->mmap_buffer = NULL; | 143 | dev_priv->mmap_buffer = NULL; |
145 | filp->f_op = old_fops; | 144 | file_priv->filp->f_op = old_fops; |
146 | if (IS_ERR((void *)virtual)) { /* ugh */ | 145 | if (IS_ERR((void *)virtual)) { /* ugh */ |
147 | /* Real error */ | 146 | /* Real error */ |
148 | DRM_ERROR("mmap error\n"); | 147 | DRM_ERROR("mmap error\n"); |
@@ -177,7 +176,7 @@ static int i830_unmap_buffer(struct drm_buf * buf) | |||
177 | } | 176 | } |
178 | 177 | ||
179 | static int i830_dma_get_buffer(struct drm_device * dev, drm_i830_dma_t * d, | 178 | static int i830_dma_get_buffer(struct drm_device * dev, drm_i830_dma_t * d, |
180 | struct file *filp) | 179 | struct drm_file *file_priv) |
181 | { | 180 | { |
182 | struct drm_buf *buf; | 181 | struct drm_buf *buf; |
183 | drm_i830_buf_priv_t *buf_priv; | 182 | drm_i830_buf_priv_t *buf_priv; |
@@ -190,13 +189,13 @@ static int i830_dma_get_buffer(struct drm_device * dev, drm_i830_dma_t * d, | |||
190 | return retcode; | 189 | return retcode; |
191 | } | 190 | } |
192 | 191 | ||
193 | retcode = i830_map_buffer(buf, filp); | 192 | retcode = i830_map_buffer(buf, file_priv); |
194 | if (retcode) { | 193 | if (retcode) { |
195 | i830_freelist_put(dev, buf); | 194 | i830_freelist_put(dev, buf); |
196 | DRM_ERROR("mapbuf failed, retcode %d\n", retcode); | 195 | DRM_ERROR("mapbuf failed, retcode %d\n", retcode); |
197 | return retcode; | 196 | return retcode; |
198 | } | 197 | } |
199 | buf->filp = filp; | 198 | buf->file_priv = file_priv; |
200 | buf_priv = buf->dev_private; | 199 | buf_priv = buf->dev_private; |
201 | d->granted = 1; | 200 | d->granted = 1; |
202 | d->request_idx = buf->idx; | 201 | d->request_idx = buf->idx; |
@@ -389,7 +388,7 @@ static int i830_dma_initialize(struct drm_device * dev, | |||
389 | i830_dma_cleanup(dev); | 388 | i830_dma_cleanup(dev); |
390 | DRM_ERROR("can not ioremap virtual address for" | 389 | DRM_ERROR("can not ioremap virtual address for" |
391 | " ring buffer\n"); | 390 | " ring buffer\n"); |
392 | return DRM_ERR(ENOMEM); | 391 | return -ENOMEM; |
393 | } | 392 | } |
394 | 393 | ||
395 | dev_priv->ring.virtual_start = dev_priv->ring.map.handle; | 394 | dev_priv->ring.virtual_start = dev_priv->ring.map.handle; |
@@ -451,25 +450,20 @@ static int i830_dma_initialize(struct drm_device * dev, | |||
451 | return 0; | 450 | return 0; |
452 | } | 451 | } |
453 | 452 | ||
454 | static int i830_dma_init(struct inode *inode, struct file *filp, | 453 | static int i830_dma_init(struct drm_device *dev, void *data, |
455 | unsigned int cmd, unsigned long arg) | 454 | struct drm_file *file_priv) |
456 | { | 455 | { |
457 | struct drm_file *priv = filp->private_data; | ||
458 | struct drm_device *dev = priv->head->dev; | ||
459 | drm_i830_private_t *dev_priv; | 456 | drm_i830_private_t *dev_priv; |
460 | drm_i830_init_t init; | 457 | drm_i830_init_t *init = data; |
461 | int retcode = 0; | 458 | int retcode = 0; |
462 | 459 | ||
463 | if (copy_from_user(&init, (void *__user)arg, sizeof(init))) | 460 | switch (init->func) { |
464 | return -EFAULT; | ||
465 | |||
466 | switch (init.func) { | ||
467 | case I830_INIT_DMA: | 461 | case I830_INIT_DMA: |
468 | dev_priv = drm_alloc(sizeof(drm_i830_private_t), | 462 | dev_priv = drm_alloc(sizeof(drm_i830_private_t), |
469 | DRM_MEM_DRIVER); | 463 | DRM_MEM_DRIVER); |
470 | if (dev_priv == NULL) | 464 | if (dev_priv == NULL) |
471 | return -ENOMEM; | 465 | return -ENOMEM; |
472 | retcode = i830_dma_initialize(dev, dev_priv, &init); | 466 | retcode = i830_dma_initialize(dev, dev_priv, init); |
473 | break; | 467 | break; |
474 | case I830_CLEANUP_DMA: | 468 | case I830_CLEANUP_DMA: |
475 | retcode = i830_dma_cleanup(dev); | 469 | retcode = i830_dma_cleanup(dev); |
@@ -1248,7 +1242,7 @@ static int i830_flush_queue(struct drm_device * dev) | |||
1248 | } | 1242 | } |
1249 | 1243 | ||
1250 | /* Must be called with the lock held */ | 1244 | /* Must be called with the lock held */ |
1251 | static void i830_reclaim_buffers(struct drm_device * dev, struct file *filp) | 1245 | static void i830_reclaim_buffers(struct drm_device * dev, struct drm_file *file_priv) |
1252 | { | 1246 | { |
1253 | struct drm_device_dma *dma = dev->dma; | 1247 | struct drm_device_dma *dma = dev->dma; |
1254 | int i; | 1248 | int i; |
@@ -1266,7 +1260,7 @@ static void i830_reclaim_buffers(struct drm_device * dev, struct file *filp) | |||
1266 | struct drm_buf *buf = dma->buflist[i]; | 1260 | struct drm_buf *buf = dma->buflist[i]; |
1267 | drm_i830_buf_priv_t *buf_priv = buf->dev_private; | 1261 | drm_i830_buf_priv_t *buf_priv = buf->dev_private; |
1268 | 1262 | ||
1269 | if (buf->filp == filp && buf_priv) { | 1263 | if (buf->file_priv == file_priv && buf_priv) { |
1270 | int used = cmpxchg(buf_priv->in_use, I830_BUF_CLIENT, | 1264 | int used = cmpxchg(buf_priv->in_use, I830_BUF_CLIENT, |
1271 | I830_BUF_FREE); | 1265 | I830_BUF_FREE); |
1272 | 1266 | ||
@@ -1278,45 +1272,36 @@ static void i830_reclaim_buffers(struct drm_device * dev, struct file *filp) | |||
1278 | } | 1272 | } |
1279 | } | 1273 | } |
1280 | 1274 | ||
1281 | static int i830_flush_ioctl(struct inode *inode, struct file *filp, | 1275 | static int i830_flush_ioctl(struct drm_device *dev, void *data, |
1282 | unsigned int cmd, unsigned long arg) | 1276 | struct drm_file *file_priv) |
1283 | { | 1277 | { |
1284 | struct drm_file *priv = filp->private_data; | 1278 | LOCK_TEST_WITH_RETURN(dev, file_priv); |
1285 | struct drm_device *dev = priv->head->dev; | ||
1286 | |||
1287 | LOCK_TEST_WITH_RETURN(dev, filp); | ||
1288 | 1279 | ||
1289 | i830_flush_queue(dev); | 1280 | i830_flush_queue(dev); |
1290 | return 0; | 1281 | return 0; |
1291 | } | 1282 | } |
1292 | 1283 | ||
1293 | static int i830_dma_vertex(struct inode *inode, struct file *filp, | 1284 | static int i830_dma_vertex(struct drm_device *dev, void *data, |
1294 | unsigned int cmd, unsigned long arg) | 1285 | struct drm_file *file_priv) |
1295 | { | 1286 | { |
1296 | struct drm_file *priv = filp->private_data; | ||
1297 | struct drm_device *dev = priv->head->dev; | ||
1298 | struct drm_device_dma *dma = dev->dma; | 1287 | struct drm_device_dma *dma = dev->dma; |
1299 | drm_i830_private_t *dev_priv = (drm_i830_private_t *) dev->dev_private; | 1288 | drm_i830_private_t *dev_priv = (drm_i830_private_t *) dev->dev_private; |
1300 | u32 *hw_status = dev_priv->hw_status_page; | 1289 | u32 *hw_status = dev_priv->hw_status_page; |
1301 | drm_i830_sarea_t *sarea_priv = (drm_i830_sarea_t *) | 1290 | drm_i830_sarea_t *sarea_priv = (drm_i830_sarea_t *) |
1302 | dev_priv->sarea_priv; | 1291 | dev_priv->sarea_priv; |
1303 | drm_i830_vertex_t vertex; | 1292 | drm_i830_vertex_t *vertex = data; |
1304 | |||
1305 | if (copy_from_user | ||
1306 | (&vertex, (drm_i830_vertex_t __user *) arg, sizeof(vertex))) | ||
1307 | return -EFAULT; | ||
1308 | 1293 | ||
1309 | LOCK_TEST_WITH_RETURN(dev, filp); | 1294 | LOCK_TEST_WITH_RETURN(dev, file_priv); |
1310 | 1295 | ||
1311 | DRM_DEBUG("i830 dma vertex, idx %d used %d discard %d\n", | 1296 | DRM_DEBUG("i830 dma vertex, idx %d used %d discard %d\n", |
1312 | vertex.idx, vertex.used, vertex.discard); | 1297 | vertex->idx, vertex->used, vertex->discard); |
1313 | 1298 | ||
1314 | if (vertex.idx < 0 || vertex.idx > dma->buf_count) | 1299 | if (vertex->idx < 0 || vertex->idx > dma->buf_count) |
1315 | return -EINVAL; | 1300 | return -EINVAL; |
1316 | 1301 | ||
1317 | i830_dma_dispatch_vertex(dev, | 1302 | i830_dma_dispatch_vertex(dev, |
1318 | dma->buflist[vertex.idx], | 1303 | dma->buflist[vertex->idx], |
1319 | vertex.discard, vertex.used); | 1304 | vertex->discard, vertex->used); |
1320 | 1305 | ||
1321 | sarea_priv->last_enqueue = dev_priv->counter - 1; | 1306 | sarea_priv->last_enqueue = dev_priv->counter - 1; |
1322 | sarea_priv->last_dispatch = (int)hw_status[5]; | 1307 | sarea_priv->last_dispatch = (int)hw_status[5]; |
@@ -1324,39 +1309,30 @@ static int i830_dma_vertex(struct inode *inode, struct file *filp, | |||
1324 | return 0; | 1309 | return 0; |
1325 | } | 1310 | } |
1326 | 1311 | ||
1327 | static int i830_clear_bufs(struct inode *inode, struct file *filp, | 1312 | static int i830_clear_bufs(struct drm_device *dev, void *data, |
1328 | unsigned int cmd, unsigned long arg) | 1313 | struct drm_file *file_priv) |
1329 | { | 1314 | { |
1330 | struct drm_file *priv = filp->private_data; | 1315 | drm_i830_clear_t *clear = data; |
1331 | struct drm_device *dev = priv->head->dev; | ||
1332 | drm_i830_clear_t clear; | ||
1333 | |||
1334 | if (copy_from_user | ||
1335 | (&clear, (drm_i830_clear_t __user *) arg, sizeof(clear))) | ||
1336 | return -EFAULT; | ||
1337 | 1316 | ||
1338 | LOCK_TEST_WITH_RETURN(dev, filp); | 1317 | LOCK_TEST_WITH_RETURN(dev, file_priv); |
1339 | 1318 | ||
1340 | /* GH: Someone's doing nasty things... */ | 1319 | /* GH: Someone's doing nasty things... */ |
1341 | if (!dev->dev_private) { | 1320 | if (!dev->dev_private) { |
1342 | return -EINVAL; | 1321 | return -EINVAL; |
1343 | } | 1322 | } |
1344 | 1323 | ||
1345 | i830_dma_dispatch_clear(dev, clear.flags, | 1324 | i830_dma_dispatch_clear(dev, clear->flags, |
1346 | clear.clear_color, | 1325 | clear->clear_color, |
1347 | clear.clear_depth, clear.clear_depthmask); | 1326 | clear->clear_depth, clear->clear_depthmask); |
1348 | return 0; | 1327 | return 0; |
1349 | } | 1328 | } |
1350 | 1329 | ||
1351 | static int i830_swap_bufs(struct inode *inode, struct file *filp, | 1330 | static int i830_swap_bufs(struct drm_device *dev, void *data, |
1352 | unsigned int cmd, unsigned long arg) | 1331 | struct drm_file *file_priv) |
1353 | { | 1332 | { |
1354 | struct drm_file *priv = filp->private_data; | ||
1355 | struct drm_device *dev = priv->head->dev; | ||
1356 | |||
1357 | DRM_DEBUG("i830_swap_bufs\n"); | 1333 | DRM_DEBUG("i830_swap_bufs\n"); |
1358 | 1334 | ||
1359 | LOCK_TEST_WITH_RETURN(dev, filp); | 1335 | LOCK_TEST_WITH_RETURN(dev, file_priv); |
1360 | 1336 | ||
1361 | i830_dma_dispatch_swap(dev); | 1337 | i830_dma_dispatch_swap(dev); |
1362 | return 0; | 1338 | return 0; |
@@ -1386,16 +1362,14 @@ static int i830_do_cleanup_pageflip(struct drm_device * dev) | |||
1386 | return 0; | 1362 | return 0; |
1387 | } | 1363 | } |
1388 | 1364 | ||
1389 | static int i830_flip_bufs(struct inode *inode, struct file *filp, | 1365 | static int i830_flip_bufs(struct drm_device *dev, void *data, |
1390 | unsigned int cmd, unsigned long arg) | 1366 | struct drm_file *file_priv) |
1391 | { | 1367 | { |
1392 | struct drm_file *priv = filp->private_data; | ||
1393 | struct drm_device *dev = priv->head->dev; | ||
1394 | drm_i830_private_t *dev_priv = dev->dev_private; | 1368 | drm_i830_private_t *dev_priv = dev->dev_private; |
1395 | 1369 | ||
1396 | DRM_DEBUG("%s\n", __FUNCTION__); | 1370 | DRM_DEBUG("%s\n", __FUNCTION__); |
1397 | 1371 | ||
1398 | LOCK_TEST_WITH_RETURN(dev, filp); | 1372 | LOCK_TEST_WITH_RETURN(dev, file_priv); |
1399 | 1373 | ||
1400 | if (!dev_priv->page_flipping) | 1374 | if (!dev_priv->page_flipping) |
1401 | i830_do_init_pageflip(dev); | 1375 | i830_do_init_pageflip(dev); |
@@ -1404,11 +1378,9 @@ static int i830_flip_bufs(struct inode *inode, struct file *filp, | |||
1404 | return 0; | 1378 | return 0; |
1405 | } | 1379 | } |
1406 | 1380 | ||
1407 | static int i830_getage(struct inode *inode, struct file *filp, unsigned int cmd, | 1381 | static int i830_getage(struct drm_device *dev, void *data, |
1408 | unsigned long arg) | 1382 | struct drm_file *file_priv) |
1409 | { | 1383 | { |
1410 | struct drm_file *priv = filp->private_data; | ||
1411 | struct drm_device *dev = priv->head->dev; | ||
1412 | drm_i830_private_t *dev_priv = (drm_i830_private_t *) dev->dev_private; | 1384 | drm_i830_private_t *dev_priv = (drm_i830_private_t *) dev->dev_private; |
1413 | u32 *hw_status = dev_priv->hw_status_page; | 1385 | u32 *hw_status = dev_priv->hw_status_page; |
1414 | drm_i830_sarea_t *sarea_priv = (drm_i830_sarea_t *) | 1386 | drm_i830_sarea_t *sarea_priv = (drm_i830_sarea_t *) |
@@ -1418,58 +1390,50 @@ static int i830_getage(struct inode *inode, struct file *filp, unsigned int cmd, | |||
1418 | return 0; | 1390 | return 0; |
1419 | } | 1391 | } |
1420 | 1392 | ||
1421 | static int i830_getbuf(struct inode *inode, struct file *filp, unsigned int cmd, | 1393 | static int i830_getbuf(struct drm_device *dev, void *data, |
1422 | unsigned long arg) | 1394 | struct drm_file *file_priv) |
1423 | { | 1395 | { |
1424 | struct drm_file *priv = filp->private_data; | ||
1425 | struct drm_device *dev = priv->head->dev; | ||
1426 | int retcode = 0; | 1396 | int retcode = 0; |
1427 | drm_i830_dma_t d; | 1397 | drm_i830_dma_t *d = data; |
1428 | drm_i830_private_t *dev_priv = (drm_i830_private_t *) dev->dev_private; | 1398 | drm_i830_private_t *dev_priv = (drm_i830_private_t *) dev->dev_private; |
1429 | u32 *hw_status = dev_priv->hw_status_page; | 1399 | u32 *hw_status = dev_priv->hw_status_page; |
1430 | drm_i830_sarea_t *sarea_priv = (drm_i830_sarea_t *) | 1400 | drm_i830_sarea_t *sarea_priv = (drm_i830_sarea_t *) |
1431 | dev_priv->sarea_priv; | 1401 | dev_priv->sarea_priv; |
1432 | 1402 | ||
1433 | DRM_DEBUG("getbuf\n"); | 1403 | DRM_DEBUG("getbuf\n"); |
1434 | if (copy_from_user(&d, (drm_i830_dma_t __user *) arg, sizeof(d))) | ||
1435 | return -EFAULT; | ||
1436 | 1404 | ||
1437 | LOCK_TEST_WITH_RETURN(dev, filp); | 1405 | LOCK_TEST_WITH_RETURN(dev, file_priv); |
1438 | 1406 | ||
1439 | d.granted = 0; | 1407 | d->granted = 0; |
1440 | 1408 | ||
1441 | retcode = i830_dma_get_buffer(dev, &d, filp); | 1409 | retcode = i830_dma_get_buffer(dev, d, file_priv); |
1442 | 1410 | ||
1443 | DRM_DEBUG("i830_dma: %d returning %d, granted = %d\n", | 1411 | DRM_DEBUG("i830_dma: %d returning %d, granted = %d\n", |
1444 | current->pid, retcode, d.granted); | 1412 | current->pid, retcode, d->granted); |
1445 | 1413 | ||
1446 | if (copy_to_user((void __user *) arg, &d, sizeof(d))) | ||
1447 | return -EFAULT; | ||
1448 | sarea_priv->last_dispatch = (int)hw_status[5]; | 1414 | sarea_priv->last_dispatch = (int)hw_status[5]; |
1449 | 1415 | ||
1450 | return retcode; | 1416 | return retcode; |
1451 | } | 1417 | } |
1452 | 1418 | ||
1453 | static int i830_copybuf(struct inode *inode, | 1419 | static int i830_copybuf(struct drm_device *dev, void *data, |
1454 | struct file *filp, unsigned int cmd, unsigned long arg) | 1420 | struct drm_file *file_priv) |
1455 | { | 1421 | { |
1456 | /* Never copy - 2.4.x doesn't need it */ | 1422 | /* Never copy - 2.4.x doesn't need it */ |
1457 | return 0; | 1423 | return 0; |
1458 | } | 1424 | } |
1459 | 1425 | ||
1460 | static int i830_docopy(struct inode *inode, struct file *filp, unsigned int cmd, | 1426 | static int i830_docopy(struct drm_device *dev, void *data, |
1461 | unsigned long arg) | 1427 | struct drm_file *file_priv) |
1462 | { | 1428 | { |
1463 | return 0; | 1429 | return 0; |
1464 | } | 1430 | } |
1465 | 1431 | ||
1466 | static int i830_getparam(struct inode *inode, struct file *filp, | 1432 | static int i830_getparam(struct drm_device *dev, void *data, |
1467 | unsigned int cmd, unsigned long arg) | 1433 | struct drm_file *file_priv) |
1468 | { | 1434 | { |
1469 | struct drm_file *priv = filp->private_data; | ||
1470 | struct drm_device *dev = priv->head->dev; | ||
1471 | drm_i830_private_t *dev_priv = dev->dev_private; | 1435 | drm_i830_private_t *dev_priv = dev->dev_private; |
1472 | drm_i830_getparam_t param; | 1436 | drm_i830_getparam_t *param = data; |
1473 | int value; | 1437 | int value; |
1474 | 1438 | ||
1475 | if (!dev_priv) { | 1439 | if (!dev_priv) { |
@@ -1477,11 +1441,7 @@ static int i830_getparam(struct inode *inode, struct file *filp, | |||
1477 | return -EINVAL; | 1441 | return -EINVAL; |
1478 | } | 1442 | } |
1479 | 1443 | ||
1480 | if (copy_from_user | 1444 | switch (param->param) { |
1481 | (¶m, (drm_i830_getparam_t __user *) arg, sizeof(param))) | ||
1482 | return -EFAULT; | ||
1483 | |||
1484 | switch (param.param) { | ||
1485 | case I830_PARAM_IRQ_ACTIVE: | 1445 | case I830_PARAM_IRQ_ACTIVE: |
1486 | value = dev->irq_enabled; | 1446 | value = dev->irq_enabled; |
1487 | break; | 1447 | break; |
@@ -1489,7 +1449,7 @@ static int i830_getparam(struct inode *inode, struct file *filp, | |||
1489 | return -EINVAL; | 1449 | return -EINVAL; |
1490 | } | 1450 | } |
1491 | 1451 | ||
1492 | if (copy_to_user(param.value, &value, sizeof(int))) { | 1452 | if (copy_to_user(param->value, &value, sizeof(int))) { |
1493 | DRM_ERROR("copy_to_user\n"); | 1453 | DRM_ERROR("copy_to_user\n"); |
1494 | return -EFAULT; | 1454 | return -EFAULT; |
1495 | } | 1455 | } |
@@ -1497,26 +1457,20 @@ static int i830_getparam(struct inode *inode, struct file *filp, | |||
1497 | return 0; | 1457 | return 0; |
1498 | } | 1458 | } |
1499 | 1459 | ||
1500 | static int i830_setparam(struct inode *inode, struct file *filp, | 1460 | static int i830_setparam(struct drm_device *dev, void *data, |
1501 | unsigned int cmd, unsigned long arg) | 1461 | struct drm_file *file_priv) |
1502 | { | 1462 | { |
1503 | struct drm_file *priv = filp->private_data; | ||
1504 | struct drm_device *dev = priv->head->dev; | ||
1505 | drm_i830_private_t *dev_priv = dev->dev_private; | 1463 | drm_i830_private_t *dev_priv = dev->dev_private; |
1506 | drm_i830_setparam_t param; | 1464 | drm_i830_setparam_t *param = data; |
1507 | 1465 | ||
1508 | if (!dev_priv) { | 1466 | if (!dev_priv) { |
1509 | DRM_ERROR("%s called with no initialization\n", __FUNCTION__); | 1467 | DRM_ERROR("%s called with no initialization\n", __FUNCTION__); |
1510 | return -EINVAL; | 1468 | return -EINVAL; |
1511 | } | 1469 | } |
1512 | 1470 | ||
1513 | if (copy_from_user | 1471 | switch (param->param) { |
1514 | (¶m, (drm_i830_setparam_t __user *) arg, sizeof(param))) | ||
1515 | return -EFAULT; | ||
1516 | |||
1517 | switch (param.param) { | ||
1518 | case I830_SETPARAM_USE_MI_BATCHBUFFER_START: | 1472 | case I830_SETPARAM_USE_MI_BATCHBUFFER_START: |
1519 | dev_priv->use_mi_batchbuffer_start = param.value; | 1473 | dev_priv->use_mi_batchbuffer_start = param->value; |
1520 | break; | 1474 | break; |
1521 | default: | 1475 | default: |
1522 | return -EINVAL; | 1476 | return -EINVAL; |
@@ -1542,7 +1496,7 @@ void i830_driver_lastclose(struct drm_device * dev) | |||
1542 | i830_dma_cleanup(dev); | 1496 | i830_dma_cleanup(dev); |
1543 | } | 1497 | } |
1544 | 1498 | ||
1545 | void i830_driver_preclose(struct drm_device * dev, DRMFILE filp) | 1499 | void i830_driver_preclose(struct drm_device * dev, struct drm_file *file_priv) |
1546 | { | 1500 | { |
1547 | if (dev->dev_private) { | 1501 | if (dev->dev_private) { |
1548 | drm_i830_private_t *dev_priv = dev->dev_private; | 1502 | drm_i830_private_t *dev_priv = dev->dev_private; |
@@ -1552,9 +1506,9 @@ void i830_driver_preclose(struct drm_device * dev, DRMFILE filp) | |||
1552 | } | 1506 | } |
1553 | } | 1507 | } |
1554 | 1508 | ||
1555 | void i830_driver_reclaim_buffers_locked(struct drm_device * dev, struct file *filp) | 1509 | void i830_driver_reclaim_buffers_locked(struct drm_device * dev, struct drm_file *file_priv) |
1556 | { | 1510 | { |
1557 | i830_reclaim_buffers(dev, filp); | 1511 | i830_reclaim_buffers(dev, file_priv); |
1558 | } | 1512 | } |
1559 | 1513 | ||
1560 | int i830_driver_dma_quiescent(struct drm_device * dev) | 1514 | int i830_driver_dma_quiescent(struct drm_device * dev) |
@@ -1563,21 +1517,21 @@ int i830_driver_dma_quiescent(struct drm_device * dev) | |||
1563 | return 0; | 1517 | return 0; |
1564 | } | 1518 | } |
1565 | 1519 | ||
1566 | drm_ioctl_desc_t i830_ioctls[] = { | 1520 | struct drm_ioctl_desc i830_ioctls[] = { |
1567 | [DRM_IOCTL_NR(DRM_I830_INIT)] = {i830_dma_init, DRM_AUTH|DRM_MASTER|DRM_ROOT_ONLY}, | 1521 | DRM_IOCTL_DEF(DRM_I830_INIT, i830_dma_init, DRM_AUTH|DRM_MASTER|DRM_ROOT_ONLY), |
1568 | [DRM_IOCTL_NR(DRM_I830_VERTEX)] = {i830_dma_vertex, DRM_AUTH}, | 1522 | DRM_IOCTL_DEF(DRM_I830_VERTEX, i830_dma_vertex, DRM_AUTH), |
1569 | [DRM_IOCTL_NR(DRM_I830_CLEAR)] = {i830_clear_bufs, DRM_AUTH}, | 1523 | DRM_IOCTL_DEF(DRM_I830_CLEAR, i830_clear_bufs, DRM_AUTH), |
1570 | [DRM_IOCTL_NR(DRM_I830_FLUSH)] = {i830_flush_ioctl, DRM_AUTH}, | 1524 | DRM_IOCTL_DEF(DRM_I830_FLUSH, i830_flush_ioctl, DRM_AUTH), |
1571 | [DRM_IOCTL_NR(DRM_I830_GETAGE)] = {i830_getage, DRM_AUTH}, | 1525 | DRM_IOCTL_DEF(DRM_I830_GETAGE, i830_getage, DRM_AUTH), |
1572 | [DRM_IOCTL_NR(DRM_I830_GETBUF)] = {i830_getbuf, DRM_AUTH}, | 1526 | DRM_IOCTL_DEF(DRM_I830_GETBUF, i830_getbuf, DRM_AUTH), |
1573 | [DRM_IOCTL_NR(DRM_I830_SWAP)] = {i830_swap_bufs, DRM_AUTH}, | 1527 | DRM_IOCTL_DEF(DRM_I830_SWAP, i830_swap_bufs, DRM_AUTH), |
1574 | [DRM_IOCTL_NR(DRM_I830_COPY)] = {i830_copybuf, DRM_AUTH}, | 1528 | DRM_IOCTL_DEF(DRM_I830_COPY, i830_copybuf, DRM_AUTH), |
1575 | [DRM_IOCTL_NR(DRM_I830_DOCOPY)] = {i830_docopy, DRM_AUTH}, | 1529 | DRM_IOCTL_DEF(DRM_I830_DOCOPY, i830_docopy, DRM_AUTH), |
1576 | [DRM_IOCTL_NR(DRM_I830_FLIP)] = {i830_flip_bufs, DRM_AUTH}, | 1530 | DRM_IOCTL_DEF(DRM_I830_FLIP, i830_flip_bufs, DRM_AUTH), |
1577 | [DRM_IOCTL_NR(DRM_I830_IRQ_EMIT)] = {i830_irq_emit, DRM_AUTH}, | 1531 | DRM_IOCTL_DEF(DRM_I830_IRQ_EMIT, i830_irq_emit, DRM_AUTH), |
1578 | [DRM_IOCTL_NR(DRM_I830_IRQ_WAIT)] = {i830_irq_wait, DRM_AUTH}, | 1532 | DRM_IOCTL_DEF(DRM_I830_IRQ_WAIT, i830_irq_wait, DRM_AUTH), |
1579 | [DRM_IOCTL_NR(DRM_I830_GETPARAM)] = {i830_getparam, DRM_AUTH}, | 1533 | DRM_IOCTL_DEF(DRM_I830_GETPARAM, i830_getparam, DRM_AUTH), |
1580 | [DRM_IOCTL_NR(DRM_I830_SETPARAM)] = {i830_setparam, DRM_AUTH} | 1534 | DRM_IOCTL_DEF(DRM_I830_SETPARAM, i830_setparam, DRM_AUTH) |
1581 | }; | 1535 | }; |
1582 | 1536 | ||
1583 | int i830_max_ioctl = DRM_ARRAY_SIZE(i830_ioctls); | 1537 | int i830_max_ioctl = DRM_ARRAY_SIZE(i830_ioctls); |