aboutsummaryrefslogtreecommitdiffstats
path: root/drivers/gpu/drm/drm_agpsupport.c
diff options
context:
space:
mode:
Diffstat (limited to 'drivers/gpu/drm/drm_agpsupport.c')
-rw-r--r--drivers/gpu/drm/drm_agpsupport.c52
1 files changed, 51 insertions, 1 deletions
diff --git a/drivers/gpu/drm/drm_agpsupport.c b/drivers/gpu/drm/drm_agpsupport.c
index aefa5ac4c0b1..3d33b8252b58 100644
--- a/drivers/gpu/drm/drm_agpsupport.c
+++ b/drivers/gpu/drm/drm_agpsupport.c
@@ -33,6 +33,7 @@
33 33
34#include "drmP.h" 34#include "drmP.h"
35#include <linux/module.h> 35#include <linux/module.h>
36#include <asm/agp.h>
36 37
37#if __OS_HAS_AGP 38#if __OS_HAS_AGP
38 39
@@ -452,4 +453,53 @@ int drm_agp_unbind_memory(DRM_AGP_MEM * handle)
452 return agp_unbind_memory(handle); 453 return agp_unbind_memory(handle);
453} 454}
454 455
455#endif /* __OS_HAS_AGP */ 456/**
457 * Binds a collection of pages into AGP memory at the given offset, returning
458 * the AGP memory structure containing them.
459 *
460 * No reference is held on the pages during this time -- it is up to the
461 * caller to handle that.
462 */
463DRM_AGP_MEM *
464drm_agp_bind_pages(struct drm_device *dev,
465 struct page **pages,
466 unsigned long num_pages,
467 uint32_t gtt_offset,
468 u32 type)
469{
470 DRM_AGP_MEM *mem;
471 int ret, i;
472
473 DRM_DEBUG("\n");
474
475 mem = drm_agp_allocate_memory(dev->agp->bridge, num_pages,
476 type);
477 if (mem == NULL) {
478 DRM_ERROR("Failed to allocate memory for %ld pages\n",
479 num_pages);
480 return NULL;
481 }
482
483 for (i = 0; i < num_pages; i++)
484 mem->memory[i] = phys_to_gart(page_to_phys(pages[i]));
485 mem->page_count = num_pages;
486
487 mem->is_flushed = true;
488 ret = drm_agp_bind_memory(mem, gtt_offset / PAGE_SIZE);
489 if (ret != 0) {
490 DRM_ERROR("Failed to bind AGP memory: %d\n", ret);
491 agp_free_memory(mem);
492 return NULL;
493 }
494
495 return mem;
496}
497EXPORT_SYMBOL(drm_agp_bind_pages);
498
499void drm_agp_chipset_flush(struct drm_device *dev)
500{
501 agp_flush_chipset(dev->agp->bridge);
502}
503EXPORT_SYMBOL(drm_agp_chipset_flush);
504
505#endif /* __OS_HAS_AGP */