diff options
Diffstat (limited to 'drivers/char/drm/i830_dma.c')
-rw-r--r-- | drivers/char/drm/i830_dma.c | 157 |
1 files changed, 61 insertions, 96 deletions
diff --git a/drivers/char/drm/i830_dma.c b/drivers/char/drm/i830_dma.c index f314f8709657..43a1f78712d6 100644 --- a/drivers/char/drm/i830_dma.c +++ b/drivers/char/drm/i830_dma.c | |||
@@ -450,24 +450,20 @@ static int i830_dma_initialize(struct drm_device * dev, | |||
450 | return 0; | 450 | return 0; |
451 | } | 451 | } |
452 | 452 | ||
453 | static int i830_dma_init(struct inode *inode, struct drm_file *file_priv, | 453 | static int i830_dma_init(struct drm_device *dev, void *data, |
454 | unsigned int cmd, unsigned long arg) | 454 | struct drm_file *file_priv) |
455 | { | 455 | { |
456 | struct drm_device *dev = file_priv->head->dev; | ||
457 | drm_i830_private_t *dev_priv; | 456 | drm_i830_private_t *dev_priv; |
458 | drm_i830_init_t init; | 457 | drm_i830_init_t *init = data; |
459 | int retcode = 0; | 458 | int retcode = 0; |
460 | 459 | ||
461 | if (copy_from_user(&init, (void *__user)arg, sizeof(init))) | 460 | switch (init->func) { |
462 | return -EFAULT; | ||
463 | |||
464 | switch (init.func) { | ||
465 | case I830_INIT_DMA: | 461 | case I830_INIT_DMA: |
466 | dev_priv = drm_alloc(sizeof(drm_i830_private_t), | 462 | dev_priv = drm_alloc(sizeof(drm_i830_private_t), |
467 | DRM_MEM_DRIVER); | 463 | DRM_MEM_DRIVER); |
468 | if (dev_priv == NULL) | 464 | if (dev_priv == NULL) |
469 | return -ENOMEM; | 465 | return -ENOMEM; |
470 | retcode = i830_dma_initialize(dev, dev_priv, &init); | 466 | retcode = i830_dma_initialize(dev, dev_priv, init); |
471 | break; | 467 | break; |
472 | case I830_CLEANUP_DMA: | 468 | case I830_CLEANUP_DMA: |
473 | retcode = i830_dma_cleanup(dev); | 469 | retcode = i830_dma_cleanup(dev); |
@@ -1276,43 +1272,36 @@ static void i830_reclaim_buffers(struct drm_device * dev, struct drm_file *file_ | |||
1276 | } | 1272 | } |
1277 | } | 1273 | } |
1278 | 1274 | ||
1279 | static int i830_flush_ioctl(struct inode *inode, struct drm_file *file_priv, | 1275 | static int i830_flush_ioctl(struct drm_device *dev, void *data, |
1280 | unsigned int cmd, unsigned long arg) | 1276 | struct drm_file *file_priv) |
1281 | { | 1277 | { |
1282 | struct drm_device *dev = file_priv->head->dev; | ||
1283 | |||
1284 | LOCK_TEST_WITH_RETURN(dev, file_priv); | 1278 | LOCK_TEST_WITH_RETURN(dev, file_priv); |
1285 | 1279 | ||
1286 | i830_flush_queue(dev); | 1280 | i830_flush_queue(dev); |
1287 | return 0; | 1281 | return 0; |
1288 | } | 1282 | } |
1289 | 1283 | ||
1290 | static int i830_dma_vertex(struct inode *inode, struct drm_file *file_priv, | 1284 | static int i830_dma_vertex(struct drm_device *dev, void *data, |
1291 | unsigned int cmd, unsigned long arg) | 1285 | struct drm_file *file_priv) |
1292 | { | 1286 | { |
1293 | struct drm_device *dev = file_priv->head->dev; | ||
1294 | struct drm_device_dma *dma = dev->dma; | 1287 | struct drm_device_dma *dma = dev->dma; |
1295 | 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; |
1296 | u32 *hw_status = dev_priv->hw_status_page; | 1289 | u32 *hw_status = dev_priv->hw_status_page; |
1297 | drm_i830_sarea_t *sarea_priv = (drm_i830_sarea_t *) | 1290 | drm_i830_sarea_t *sarea_priv = (drm_i830_sarea_t *) |
1298 | dev_priv->sarea_priv; | 1291 | dev_priv->sarea_priv; |
1299 | drm_i830_vertex_t vertex; | 1292 | drm_i830_vertex_t *vertex = data; |
1300 | |||
1301 | if (copy_from_user | ||
1302 | (&vertex, (drm_i830_vertex_t __user *) arg, sizeof(vertex))) | ||
1303 | return -EFAULT; | ||
1304 | 1293 | ||
1305 | LOCK_TEST_WITH_RETURN(dev, file_priv); | 1294 | LOCK_TEST_WITH_RETURN(dev, file_priv); |
1306 | 1295 | ||
1307 | 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", |
1308 | vertex.idx, vertex.used, vertex.discard); | 1297 | vertex->idx, vertex->used, vertex->discard); |
1309 | 1298 | ||
1310 | if (vertex.idx < 0 || vertex.idx > dma->buf_count) | 1299 | if (vertex->idx < 0 || vertex->idx > dma->buf_count) |
1311 | return -EINVAL; | 1300 | return -EINVAL; |
1312 | 1301 | ||
1313 | i830_dma_dispatch_vertex(dev, | 1302 | i830_dma_dispatch_vertex(dev, |
1314 | dma->buflist[vertex.idx], | 1303 | dma->buflist[vertex->idx], |
1315 | vertex.discard, vertex.used); | 1304 | vertex->discard, vertex->used); |
1316 | 1305 | ||
1317 | sarea_priv->last_enqueue = dev_priv->counter - 1; | 1306 | sarea_priv->last_enqueue = dev_priv->counter - 1; |
1318 | sarea_priv->last_dispatch = (int)hw_status[5]; | 1307 | sarea_priv->last_dispatch = (int)hw_status[5]; |
@@ -1320,15 +1309,10 @@ static int i830_dma_vertex(struct inode *inode, struct drm_file *file_priv, | |||
1320 | return 0; | 1309 | return 0; |
1321 | } | 1310 | } |
1322 | 1311 | ||
1323 | static int i830_clear_bufs(struct inode *inode, struct drm_file *file_priv, | 1312 | static int i830_clear_bufs(struct drm_device *dev, void *data, |
1324 | unsigned int cmd, unsigned long arg) | 1313 | struct drm_file *file_priv) |
1325 | { | 1314 | { |
1326 | struct drm_device *dev = file_priv->head->dev; | 1315 | drm_i830_clear_t *clear = data; |
1327 | drm_i830_clear_t clear; | ||
1328 | |||
1329 | if (copy_from_user | ||
1330 | (&clear, (drm_i830_clear_t __user *) arg, sizeof(clear))) | ||
1331 | return -EFAULT; | ||
1332 | 1316 | ||
1333 | LOCK_TEST_WITH_RETURN(dev, file_priv); | 1317 | LOCK_TEST_WITH_RETURN(dev, file_priv); |
1334 | 1318 | ||
@@ -1337,17 +1321,15 @@ static int i830_clear_bufs(struct inode *inode, struct drm_file *file_priv, | |||
1337 | return -EINVAL; | 1321 | return -EINVAL; |
1338 | } | 1322 | } |
1339 | 1323 | ||
1340 | i830_dma_dispatch_clear(dev, clear.flags, | 1324 | i830_dma_dispatch_clear(dev, clear->flags, |
1341 | clear.clear_color, | 1325 | clear->clear_color, |
1342 | clear.clear_depth, clear.clear_depthmask); | 1326 | clear->clear_depth, clear->clear_depthmask); |
1343 | return 0; | 1327 | return 0; |
1344 | } | 1328 | } |
1345 | 1329 | ||
1346 | static int i830_swap_bufs(struct inode *inode, struct drm_file *file_priv, | 1330 | static int i830_swap_bufs(struct drm_device *dev, void *data, |
1347 | unsigned int cmd, unsigned long arg) | 1331 | struct drm_file *file_priv) |
1348 | { | 1332 | { |
1349 | struct drm_device *dev = file_priv->head->dev; | ||
1350 | |||
1351 | DRM_DEBUG("i830_swap_bufs\n"); | 1333 | DRM_DEBUG("i830_swap_bufs\n"); |
1352 | 1334 | ||
1353 | LOCK_TEST_WITH_RETURN(dev, file_priv); | 1335 | LOCK_TEST_WITH_RETURN(dev, file_priv); |
@@ -1380,10 +1362,9 @@ static int i830_do_cleanup_pageflip(struct drm_device * dev) | |||
1380 | return 0; | 1362 | return 0; |
1381 | } | 1363 | } |
1382 | 1364 | ||
1383 | static int i830_flip_bufs(struct inode *inode, struct drm_file *file_priv, | 1365 | static int i830_flip_bufs(struct drm_device *dev, void *data, |
1384 | unsigned int cmd, unsigned long arg) | 1366 | struct drm_file *file_priv) |
1385 | { | 1367 | { |
1386 | struct drm_device *dev = file_priv->head->dev; | ||
1387 | drm_i830_private_t *dev_priv = dev->dev_private; | 1368 | drm_i830_private_t *dev_priv = dev->dev_private; |
1388 | 1369 | ||
1389 | DRM_DEBUG("%s\n", __FUNCTION__); | 1370 | DRM_DEBUG("%s\n", __FUNCTION__); |
@@ -1397,10 +1378,9 @@ static int i830_flip_bufs(struct inode *inode, struct drm_file *file_priv, | |||
1397 | return 0; | 1378 | return 0; |
1398 | } | 1379 | } |
1399 | 1380 | ||
1400 | static int i830_getage(struct inode *inode, struct drm_file *file_priv, unsigned int cmd, | 1381 | static int i830_getage(struct drm_device *dev, void *data, |
1401 | unsigned long arg) | 1382 | struct drm_file *file_priv) |
1402 | { | 1383 | { |
1403 | struct drm_device *dev = file_priv->head->dev; | ||
1404 | 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; |
1405 | u32 *hw_status = dev_priv->hw_status_page; | 1385 | u32 *hw_status = dev_priv->hw_status_page; |
1406 | drm_i830_sarea_t *sarea_priv = (drm_i830_sarea_t *) | 1386 | drm_i830_sarea_t *sarea_priv = (drm_i830_sarea_t *) |
@@ -1410,56 +1390,50 @@ static int i830_getage(struct inode *inode, struct drm_file *file_priv, unsigned | |||
1410 | return 0; | 1390 | return 0; |
1411 | } | 1391 | } |
1412 | 1392 | ||
1413 | static int i830_getbuf(struct inode *inode, struct drm_file *file_priv, | 1393 | static int i830_getbuf(struct drm_device *dev, void *data, |
1414 | unsigned int cmd, unsigned long arg) | 1394 | struct drm_file *file_priv) |
1415 | { | 1395 | { |
1416 | struct drm_device *dev = file_priv->head->dev; | ||
1417 | int retcode = 0; | 1396 | int retcode = 0; |
1418 | drm_i830_dma_t d; | 1397 | drm_i830_dma_t *d = data; |
1419 | 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; |
1420 | u32 *hw_status = dev_priv->hw_status_page; | 1399 | u32 *hw_status = dev_priv->hw_status_page; |
1421 | drm_i830_sarea_t *sarea_priv = (drm_i830_sarea_t *) | 1400 | drm_i830_sarea_t *sarea_priv = (drm_i830_sarea_t *) |
1422 | dev_priv->sarea_priv; | 1401 | dev_priv->sarea_priv; |
1423 | 1402 | ||
1424 | DRM_DEBUG("getbuf\n"); | 1403 | DRM_DEBUG("getbuf\n"); |
1425 | if (copy_from_user(&d, (drm_i830_dma_t __user *) arg, sizeof(d))) | ||
1426 | return -EFAULT; | ||
1427 | 1404 | ||
1428 | LOCK_TEST_WITH_RETURN(dev, file_priv); | 1405 | LOCK_TEST_WITH_RETURN(dev, file_priv); |
1429 | 1406 | ||
1430 | d.granted = 0; | 1407 | d->granted = 0; |
1431 | 1408 | ||
1432 | retcode = i830_dma_get_buffer(dev, &d, file_priv); | 1409 | retcode = i830_dma_get_buffer(dev, d, file_priv); |
1433 | 1410 | ||
1434 | DRM_DEBUG("i830_dma: %d returning %d, granted = %d\n", | 1411 | DRM_DEBUG("i830_dma: %d returning %d, granted = %d\n", |
1435 | current->pid, retcode, d.granted); | 1412 | current->pid, retcode, d->granted); |
1436 | 1413 | ||
1437 | if (copy_to_user((void __user *) arg, &d, sizeof(d))) | ||
1438 | return -EFAULT; | ||
1439 | sarea_priv->last_dispatch = (int)hw_status[5]; | 1414 | sarea_priv->last_dispatch = (int)hw_status[5]; |
1440 | 1415 | ||
1441 | return retcode; | 1416 | return retcode; |
1442 | } | 1417 | } |
1443 | 1418 | ||
1444 | static int i830_copybuf(struct inode *inode, | 1419 | static int i830_copybuf(struct drm_device *dev, void *data, |
1445 | struct drm_file *file_priv, unsigned int cmd, unsigned long arg) | 1420 | struct drm_file *file_priv) |
1446 | { | 1421 | { |
1447 | /* Never copy - 2.4.x doesn't need it */ | 1422 | /* Never copy - 2.4.x doesn't need it */ |
1448 | return 0; | 1423 | return 0; |
1449 | } | 1424 | } |
1450 | 1425 | ||
1451 | static int i830_docopy(struct inode *inode, struct drm_file *file_priv, unsigned int cmd, | 1426 | static int i830_docopy(struct drm_device *dev, void *data, |
1452 | unsigned long arg) | 1427 | struct drm_file *file_priv) |
1453 | { | 1428 | { |
1454 | return 0; | 1429 | return 0; |
1455 | } | 1430 | } |
1456 | 1431 | ||
1457 | static int i830_getparam(struct inode *inode, struct drm_file *file_priv, | 1432 | static int i830_getparam(struct drm_device *dev, void *data, |
1458 | unsigned int cmd, unsigned long arg) | 1433 | struct drm_file *file_priv) |
1459 | { | 1434 | { |
1460 | struct drm_device *dev = file_priv->head->dev; | ||
1461 | drm_i830_private_t *dev_priv = dev->dev_private; | 1435 | drm_i830_private_t *dev_priv = dev->dev_private; |
1462 | drm_i830_getparam_t param; | 1436 | drm_i830_getparam_t *param = data; |
1463 | int value; | 1437 | int value; |
1464 | 1438 | ||
1465 | if (!dev_priv) { | 1439 | if (!dev_priv) { |
@@ -1467,11 +1441,7 @@ static int i830_getparam(struct inode *inode, struct drm_file *file_priv, | |||
1467 | return -EINVAL; | 1441 | return -EINVAL; |
1468 | } | 1442 | } |
1469 | 1443 | ||
1470 | if (copy_from_user | 1444 | switch (param->param) { |
1471 | (¶m, (drm_i830_getparam_t __user *) arg, sizeof(param))) | ||
1472 | return -EFAULT; | ||
1473 | |||
1474 | switch (param.param) { | ||
1475 | case I830_PARAM_IRQ_ACTIVE: | 1445 | case I830_PARAM_IRQ_ACTIVE: |
1476 | value = dev->irq_enabled; | 1446 | value = dev->irq_enabled; |
1477 | break; | 1447 | break; |
@@ -1479,7 +1449,7 @@ static int i830_getparam(struct inode *inode, struct drm_file *file_priv, | |||
1479 | return -EINVAL; | 1449 | return -EINVAL; |
1480 | } | 1450 | } |
1481 | 1451 | ||
1482 | if (copy_to_user(param.value, &value, sizeof(int))) { | 1452 | if (copy_to_user(param->value, &value, sizeof(int))) { |
1483 | DRM_ERROR("copy_to_user\n"); | 1453 | DRM_ERROR("copy_to_user\n"); |
1484 | return -EFAULT; | 1454 | return -EFAULT; |
1485 | } | 1455 | } |
@@ -1487,25 +1457,20 @@ static int i830_getparam(struct inode *inode, struct drm_file *file_priv, | |||
1487 | return 0; | 1457 | return 0; |
1488 | } | 1458 | } |
1489 | 1459 | ||
1490 | static int i830_setparam(struct inode *inode, struct drm_file *file_priv, | 1460 | static int i830_setparam(struct drm_device *dev, void *data, |
1491 | unsigned int cmd, unsigned long arg) | 1461 | struct drm_file *file_priv) |
1492 | { | 1462 | { |
1493 | struct drm_device *dev = file_priv->head->dev; | ||
1494 | drm_i830_private_t *dev_priv = dev->dev_private; | 1463 | drm_i830_private_t *dev_priv = dev->dev_private; |
1495 | drm_i830_setparam_t param; | 1464 | drm_i830_setparam_t *param = data; |
1496 | 1465 | ||
1497 | if (!dev_priv) { | 1466 | if (!dev_priv) { |
1498 | DRM_ERROR("%s called with no initialization\n", __FUNCTION__); | 1467 | DRM_ERROR("%s called with no initialization\n", __FUNCTION__); |
1499 | return -EINVAL; | 1468 | return -EINVAL; |
1500 | } | 1469 | } |
1501 | 1470 | ||
1502 | if (copy_from_user | 1471 | switch (param->param) { |
1503 | (¶m, (drm_i830_setparam_t __user *) arg, sizeof(param))) | ||
1504 | return -EFAULT; | ||
1505 | |||
1506 | switch (param.param) { | ||
1507 | case I830_SETPARAM_USE_MI_BATCHBUFFER_START: | 1472 | case I830_SETPARAM_USE_MI_BATCHBUFFER_START: |
1508 | dev_priv->use_mi_batchbuffer_start = param.value; | 1473 | dev_priv->use_mi_batchbuffer_start = param->value; |
1509 | break; | 1474 | break; |
1510 | default: | 1475 | default: |
1511 | return -EINVAL; | 1476 | return -EINVAL; |
@@ -1552,21 +1517,21 @@ int i830_driver_dma_quiescent(struct drm_device * dev) | |||
1552 | return 0; | 1517 | return 0; |
1553 | } | 1518 | } |
1554 | 1519 | ||
1555 | drm_ioctl_desc_t i830_ioctls[] = { | 1520 | struct drm_ioctl_desc i830_ioctls[] = { |
1556 | [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), |
1557 | [DRM_IOCTL_NR(DRM_I830_VERTEX)] = {i830_dma_vertex, DRM_AUTH}, | 1522 | DRM_IOCTL_DEF(DRM_I830_VERTEX, i830_dma_vertex, DRM_AUTH), |
1558 | [DRM_IOCTL_NR(DRM_I830_CLEAR)] = {i830_clear_bufs, DRM_AUTH}, | 1523 | DRM_IOCTL_DEF(DRM_I830_CLEAR, i830_clear_bufs, DRM_AUTH), |
1559 | [DRM_IOCTL_NR(DRM_I830_FLUSH)] = {i830_flush_ioctl, DRM_AUTH}, | 1524 | DRM_IOCTL_DEF(DRM_I830_FLUSH, i830_flush_ioctl, DRM_AUTH), |
1560 | [DRM_IOCTL_NR(DRM_I830_GETAGE)] = {i830_getage, DRM_AUTH}, | 1525 | DRM_IOCTL_DEF(DRM_I830_GETAGE, i830_getage, DRM_AUTH), |
1561 | [DRM_IOCTL_NR(DRM_I830_GETBUF)] = {i830_getbuf, DRM_AUTH}, | 1526 | DRM_IOCTL_DEF(DRM_I830_GETBUF, i830_getbuf, DRM_AUTH), |
1562 | [DRM_IOCTL_NR(DRM_I830_SWAP)] = {i830_swap_bufs, DRM_AUTH}, | 1527 | DRM_IOCTL_DEF(DRM_I830_SWAP, i830_swap_bufs, DRM_AUTH), |
1563 | [DRM_IOCTL_NR(DRM_I830_COPY)] = {i830_copybuf, DRM_AUTH}, | 1528 | DRM_IOCTL_DEF(DRM_I830_COPY, i830_copybuf, DRM_AUTH), |
1564 | [DRM_IOCTL_NR(DRM_I830_DOCOPY)] = {i830_docopy, DRM_AUTH}, | 1529 | DRM_IOCTL_DEF(DRM_I830_DOCOPY, i830_docopy, DRM_AUTH), |
1565 | [DRM_IOCTL_NR(DRM_I830_FLIP)] = {i830_flip_bufs, DRM_AUTH}, | 1530 | DRM_IOCTL_DEF(DRM_I830_FLIP, i830_flip_bufs, DRM_AUTH), |
1566 | [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), |
1567 | [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), |
1568 | [DRM_IOCTL_NR(DRM_I830_GETPARAM)] = {i830_getparam, DRM_AUTH}, | 1533 | DRM_IOCTL_DEF(DRM_I830_GETPARAM, i830_getparam, DRM_AUTH), |
1569 | [DRM_IOCTL_NR(DRM_I830_SETPARAM)] = {i830_setparam, DRM_AUTH} | 1534 | DRM_IOCTL_DEF(DRM_I830_SETPARAM, i830_setparam, DRM_AUTH) |
1570 | }; | 1535 | }; |
1571 | 1536 | ||
1572 | int i830_max_ioctl = DRM_ARRAY_SIZE(i830_ioctls); | 1537 | int i830_max_ioctl = DRM_ARRAY_SIZE(i830_ioctls); |