aboutsummaryrefslogtreecommitdiffstats
path: root/include/drm/drmP.h
diff options
context:
space:
mode:
authorJesse Barnes <jbarnes@virtuousgeek.org>2008-11-05 13:31:53 -0500
committerDave Airlie <airlied@linux.ie>2008-12-29 02:47:22 -0500
commita2c0a97b784f837300f7b0869c82ab712c600952 (patch)
treeaca1cdf3d32e1cfa7387350483f6a70c74a24ffd /include/drm/drmP.h
parenta9587470f753d670d910293ecbf1c7b66c99de50 (diff)
drm: GEM mmap support
Add core support for mapping of GEM objects. Drivers should provide a vm_operations_struct if they want to support page faulting of objects. The code for handling GEM object offsets was taken from TTM, which was written by Thomas Hellström. Signed-off-by: Jesse Barnes <jbarnes@virtuousgeek.org> Signed-off-by: Eric Anholt <eric@anholt.net> Signed-off-by: Dave Airlie <airlied@redhat.com>
Diffstat (limited to 'include/drm/drmP.h')
-rw-r--r--include/drm/drmP.h21
1 files changed, 21 insertions, 0 deletions
diff --git a/include/drm/drmP.h b/include/drm/drmP.h
index c9cc618dbcfc..ae42a6a5c24e 100644
--- a/include/drm/drmP.h
+++ b/include/drm/drmP.h
@@ -528,6 +528,7 @@ struct drm_map_list {
528 struct drm_map *map; /**< mapping */ 528 struct drm_map *map; /**< mapping */
529 uint64_t user_token; 529 uint64_t user_token;
530 struct drm_master *master; 530 struct drm_master *master;
531 struct drm_mm_node *file_offset_node; /**< fake offset */
531}; 532};
532 533
533typedef struct drm_map drm_local_map_t; 534typedef struct drm_map drm_local_map_t;
@@ -568,6 +569,14 @@ struct drm_ati_pcigart_info {
568}; 569};
569 570
570/** 571/**
572 * GEM specific mm private for tracking GEM objects
573 */
574struct drm_gem_mm {
575 struct drm_mm offset_manager; /**< Offset mgmt for buffer objects */
576 struct drm_open_hash offset_hash; /**< User token hash table for maps */
577};
578
579/**
571 * This structure defines the drm_mm memory object, which will be used by the 580 * This structure defines the drm_mm memory object, which will be used by the
572 * DRM for its buffer objects. 581 * DRM for its buffer objects.
573 */ 582 */
@@ -584,6 +593,9 @@ struct drm_gem_object {
584 /** File representing the shmem storage */ 593 /** File representing the shmem storage */
585 struct file *filp; 594 struct file *filp;
586 595
596 /* Mapping info for this object */
597 struct drm_map_list map_list;
598
587 /** 599 /**
588 * Size of the object, in bytes. Immutable over the object's 600 * Size of the object, in bytes. Immutable over the object's
589 * lifetime. 601 * lifetime.
@@ -758,6 +770,9 @@ struct drm_driver {
758 int (*gem_init_object) (struct drm_gem_object *obj); 770 int (*gem_init_object) (struct drm_gem_object *obj);
759 void (*gem_free_object) (struct drm_gem_object *obj); 771 void (*gem_free_object) (struct drm_gem_object *obj);
760 772
773 /* Driver private ops for this object */
774 struct vm_operations_struct *gem_vm_ops;
775
761 int major; 776 int major;
762 int minor; 777 int minor;
763 int patchlevel; 778 int patchlevel;
@@ -910,6 +925,8 @@ struct drm_device {
910 struct drm_sg_mem *sg; /**< Scatter gather memory */ 925 struct drm_sg_mem *sg; /**< Scatter gather memory */
911 int num_crtcs; /**< Number of CRTCs on this device */ 926 int num_crtcs; /**< Number of CRTCs on this device */
912 void *dev_private; /**< device private data */ 927 void *dev_private; /**< device private data */
928 void *mm_private;
929 struct address_space *dev_mapping;
913 struct drm_sigdata sigdata; /**< For block_all_signals */ 930 struct drm_sigdata sigdata; /**< For block_all_signals */
914 sigset_t sigmask; 931 sigset_t sigmask;
915 932
@@ -1026,6 +1043,8 @@ extern int drm_release(struct inode *inode, struct file *filp);
1026 1043
1027 /* Mapping support (drm_vm.h) */ 1044 /* Mapping support (drm_vm.h) */
1028extern int drm_mmap(struct file *filp, struct vm_area_struct *vma); 1045extern int drm_mmap(struct file *filp, struct vm_area_struct *vma);
1046extern int drm_mmap_locked(struct file *filp, struct vm_area_struct *vma);
1047extern void drm_vm_open_locked(struct vm_area_struct *vma);
1029extern unsigned long drm_core_get_map_ofs(struct drm_map * map); 1048extern unsigned long drm_core_get_map_ofs(struct drm_map * map);
1030extern unsigned long drm_core_get_reg_ofs(struct drm_device *dev); 1049extern unsigned long drm_core_get_reg_ofs(struct drm_device *dev);
1031extern unsigned int drm_poll(struct file *filp, struct poll_table_struct *wait); 1050extern unsigned int drm_poll(struct file *filp, struct poll_table_struct *wait);
@@ -1287,10 +1306,12 @@ extern int drm_mm_add_space_to_tail(struct drm_mm *mm, unsigned long size);
1287 1306
1288/* Graphics Execution Manager library functions (drm_gem.c) */ 1307/* Graphics Execution Manager library functions (drm_gem.c) */
1289int drm_gem_init(struct drm_device *dev); 1308int drm_gem_init(struct drm_device *dev);
1309void drm_gem_destroy(struct drm_device *dev);
1290void drm_gem_object_free(struct kref *kref); 1310void drm_gem_object_free(struct kref *kref);
1291struct drm_gem_object *drm_gem_object_alloc(struct drm_device *dev, 1311struct drm_gem_object *drm_gem_object_alloc(struct drm_device *dev,
1292 size_t size); 1312 size_t size);
1293void drm_gem_object_handle_free(struct kref *kref); 1313void drm_gem_object_handle_free(struct kref *kref);
1314int drm_gem_mmap(struct file *filp, struct vm_area_struct *vma);
1294 1315
1295static inline void 1316static inline void
1296drm_gem_object_reference(struct drm_gem_object *obj) 1317drm_gem_object_reference(struct drm_gem_object *obj)