diff options
| author | Daniel Vetter <daniel.vetter@ffwll.ch> | 2014-09-23 09:46:53 -0400 |
|---|---|---|
| committer | Dave Airlie <airlied@redhat.com> | 2014-09-23 21:43:41 -0400 |
| commit | d9fc9413f97f5c615256a5657ec667c064c07a70 (patch) | |
| tree | 42f6e33995c93f08e96dcfc886c2aaa1e45d2c72 /include/drm | |
| parent | c2611031b49e9ccd571a3737845af3fca2a2090f (diff) | |
drm: Extract <drm/drm_gem.h>
v2: Don't forget git add, noticed by David.
Cc: David Herrmann <dh.herrmann@gmail.com>
Signed-off-by: Daniel Vetter <daniel.vetter@intel.com>
Acked-by: David Herrmann <dh.herrmann@gmail.com>
Acked-by: Alex Deucher <alexander.deucher@amd.com>
Signed-off-by: Dave Airlie <airlied@redhat.com>
Diffstat (limited to 'include/drm')
| -rw-r--r-- | include/drm/drmP.h | 148 | ||||
| -rw-r--r-- | include/drm/drm_gem.h | 183 | ||||
| -rw-r--r-- | include/drm/drm_gem_cma_helper.h | 1 |
3 files changed, 185 insertions, 147 deletions
diff --git a/include/drm/drmP.h b/include/drm/drmP.h index 6656fd7d64d4..d2c2b7f3a4e2 100644 --- a/include/drm/drmP.h +++ b/include/drm/drmP.h | |||
| @@ -82,6 +82,7 @@ struct drm_agp_head; | |||
| 82 | struct drm_local_map; | 82 | struct drm_local_map; |
| 83 | struct drm_device_dma; | 83 | struct drm_device_dma; |
| 84 | struct drm_dma_handle; | 84 | struct drm_dma_handle; |
| 85 | struct drm_gem_object; | ||
| 85 | 86 | ||
| 86 | struct device_node; | 87 | struct device_node; |
| 87 | struct videomode; | 88 | struct videomode; |
| @@ -331,93 +332,6 @@ struct drm_lock_data { | |||
| 331 | }; | 332 | }; |
| 332 | 333 | ||
| 333 | /** | 334 | /** |
| 334 | * This structure defines the drm_mm memory object, which will be used by the | ||
| 335 | * DRM for its buffer objects. | ||
| 336 | */ | ||
| 337 | struct drm_gem_object { | ||
| 338 | /** Reference count of this object */ | ||
| 339 | struct kref refcount; | ||
| 340 | |||
| 341 | /** | ||
| 342 | * handle_count - gem file_priv handle count of this object | ||
| 343 | * | ||
| 344 | * Each handle also holds a reference. Note that when the handle_count | ||
| 345 | * drops to 0 any global names (e.g. the id in the flink namespace) will | ||
| 346 | * be cleared. | ||
| 347 | * | ||
| 348 | * Protected by dev->object_name_lock. | ||
| 349 | * */ | ||
| 350 | unsigned handle_count; | ||
| 351 | |||
| 352 | /** Related drm device */ | ||
| 353 | struct drm_device *dev; | ||
| 354 | |||
| 355 | /** File representing the shmem storage */ | ||
| 356 | struct file *filp; | ||
| 357 | |||
| 358 | /* Mapping info for this object */ | ||
| 359 | struct drm_vma_offset_node vma_node; | ||
| 360 | |||
| 361 | /** | ||
| 362 | * Size of the object, in bytes. Immutable over the object's | ||
| 363 | * lifetime. | ||
| 364 | */ | ||
| 365 | size_t size; | ||
| 366 | |||
| 367 | /** | ||
| 368 | * Global name for this object, starts at 1. 0 means unnamed. | ||
| 369 | * Access is covered by the object_name_lock in the related drm_device | ||
| 370 | */ | ||
| 371 | int name; | ||
| 372 | |||
| 373 | /** | ||
| 374 | * Memory domains. These monitor which caches contain read/write data | ||
| 375 | * related to the object. When transitioning from one set of domains | ||
| 376 | * to another, the driver is called to ensure that caches are suitably | ||
| 377 | * flushed and invalidated | ||
| 378 | */ | ||
| 379 | uint32_t read_domains; | ||
| 380 | uint32_t write_domain; | ||
| 381 | |||
| 382 | /** | ||
| 383 | * While validating an exec operation, the | ||
| 384 | * new read/write domain values are computed here. | ||
| 385 | * They will be transferred to the above values | ||
| 386 | * at the point that any cache flushing occurs | ||
| 387 | */ | ||
| 388 | uint32_t pending_read_domains; | ||
| 389 | uint32_t pending_write_domain; | ||
| 390 | |||
| 391 | /** | ||
| 392 | * dma_buf - dma buf associated with this GEM object | ||
| 393 | * | ||
| 394 | * Pointer to the dma-buf associated with this gem object (either | ||
| 395 | * through importing or exporting). We break the resulting reference | ||
| 396 | * loop when the last gem handle for this object is released. | ||
| 397 | * | ||
| 398 | * Protected by obj->object_name_lock | ||
| 399 | */ | ||
| 400 | struct dma_buf *dma_buf; | ||
| 401 | |||
| 402 | /** | ||
| 403 | * import_attach - dma buf attachment backing this object | ||
| 404 | * | ||
| 405 | * Any foreign dma_buf imported as a gem object has this set to the | ||
| 406 | * attachment point for the device. This is invariant over the lifetime | ||
| 407 | * of a gem object. | ||
| 408 | * | ||
| 409 | * The driver's ->gem_free_object callback is responsible for cleaning | ||
| 410 | * up the dma_buf attachment and references acquired at import time. | ||
| 411 | * | ||
| 412 | * Note that the drm gem/prime core does not depend upon drivers setting | ||
| 413 | * this field any more. So for drivers where this doesn't make sense | ||
| 414 | * (e.g. virtual devices or a displaylink behind an usb bus) they can | ||
| 415 | * simply leave it as NULL. | ||
| 416 | */ | ||
| 417 | struct dma_buf_attachment *import_attach; | ||
| 418 | }; | ||
| 419 | |||
| 420 | /** | ||
| 421 | * struct drm_master - drm master structure | 335 | * struct drm_master - drm master structure |
| 422 | * | 336 | * |
| 423 | * @refcount: Refcount for this master object. | 337 | * @refcount: Refcount for this master object. |
| @@ -1073,10 +987,6 @@ extern int drm_prime_sg_to_page_addr_arrays(struct sg_table *sgt, struct page ** | |||
| 1073 | extern struct sg_table *drm_prime_pages_to_sg(struct page **pages, int nr_pages); | 987 | extern struct sg_table *drm_prime_pages_to_sg(struct page **pages, int nr_pages); |
| 1074 | extern void drm_prime_gem_destroy(struct drm_gem_object *obj, struct sg_table *sg); | 988 | extern void drm_prime_gem_destroy(struct drm_gem_object *obj, struct sg_table *sg); |
| 1075 | 989 | ||
| 1076 | int drm_gem_dumb_destroy(struct drm_file *file, | ||
| 1077 | struct drm_device *dev, | ||
| 1078 | uint32_t handle); | ||
| 1079 | |||
| 1080 | 990 | ||
| 1081 | extern struct drm_dma_handle *drm_pci_alloc(struct drm_device *dev, size_t size, | 991 | extern struct drm_dma_handle *drm_pci_alloc(struct drm_device *dev, size_t size, |
| 1082 | size_t align); | 992 | size_t align); |
| @@ -1085,62 +995,6 @@ extern void drm_pci_free(struct drm_device *dev, struct drm_dma_handle * dmah); | |||
| 1085 | /* sysfs support (drm_sysfs.c) */ | 995 | /* sysfs support (drm_sysfs.c) */ |
| 1086 | extern void drm_sysfs_hotplug_event(struct drm_device *dev); | 996 | extern void drm_sysfs_hotplug_event(struct drm_device *dev); |
| 1087 | 997 | ||
| 1088 | /* Graphics Execution Manager library functions (drm_gem.c) */ | ||
| 1089 | void drm_gem_object_release(struct drm_gem_object *obj); | ||
| 1090 | void drm_gem_object_free(struct kref *kref); | ||
| 1091 | int drm_gem_object_init(struct drm_device *dev, | ||
| 1092 | struct drm_gem_object *obj, size_t size); | ||
| 1093 | void drm_gem_private_object_init(struct drm_device *dev, | ||
| 1094 | struct drm_gem_object *obj, size_t size); | ||
| 1095 | void drm_gem_vm_open(struct vm_area_struct *vma); | ||
| 1096 | void drm_gem_vm_close(struct vm_area_struct *vma); | ||
| 1097 | int drm_gem_mmap_obj(struct drm_gem_object *obj, unsigned long obj_size, | ||
| 1098 | struct vm_area_struct *vma); | ||
| 1099 | int drm_gem_mmap(struct file *filp, struct vm_area_struct *vma); | ||
| 1100 | |||
| 1101 | static inline void | ||
| 1102 | drm_gem_object_reference(struct drm_gem_object *obj) | ||
| 1103 | { | ||
| 1104 | kref_get(&obj->refcount); | ||
| 1105 | } | ||
| 1106 | |||
| 1107 | static inline void | ||
| 1108 | drm_gem_object_unreference(struct drm_gem_object *obj) | ||
| 1109 | { | ||
| 1110 | if (obj != NULL) | ||
| 1111 | kref_put(&obj->refcount, drm_gem_object_free); | ||
| 1112 | } | ||
| 1113 | |||
| 1114 | static inline void | ||
| 1115 | drm_gem_object_unreference_unlocked(struct drm_gem_object *obj) | ||
| 1116 | { | ||
| 1117 | if (obj && !atomic_add_unless(&obj->refcount.refcount, -1, 1)) { | ||
| 1118 | struct drm_device *dev = obj->dev; | ||
| 1119 | |||
| 1120 | mutex_lock(&dev->struct_mutex); | ||
| 1121 | if (likely(atomic_dec_and_test(&obj->refcount.refcount))) | ||
| 1122 | drm_gem_object_free(&obj->refcount); | ||
| 1123 | mutex_unlock(&dev->struct_mutex); | ||
| 1124 | } | ||
| 1125 | } | ||
| 1126 | |||
| 1127 | int drm_gem_handle_create(struct drm_file *file_priv, | ||
| 1128 | struct drm_gem_object *obj, | ||
| 1129 | u32 *handlep); | ||
| 1130 | int drm_gem_handle_delete(struct drm_file *filp, u32 handle); | ||
| 1131 | |||
| 1132 | |||
| 1133 | void drm_gem_free_mmap_offset(struct drm_gem_object *obj); | ||
| 1134 | int drm_gem_create_mmap_offset(struct drm_gem_object *obj); | ||
| 1135 | int drm_gem_create_mmap_offset_size(struct drm_gem_object *obj, size_t size); | ||
| 1136 | |||
| 1137 | struct page **drm_gem_get_pages(struct drm_gem_object *obj); | ||
| 1138 | void drm_gem_put_pages(struct drm_gem_object *obj, struct page **pages, | ||
| 1139 | bool dirty, bool accessed); | ||
| 1140 | |||
| 1141 | struct drm_gem_object *drm_gem_object_lookup(struct drm_device *dev, | ||
| 1142 | struct drm_file *filp, | ||
| 1143 | u32 handle); | ||
| 1144 | 998 | ||
| 1145 | struct drm_device *drm_dev_alloc(struct drm_driver *driver, | 999 | struct drm_device *drm_dev_alloc(struct drm_driver *driver, |
| 1146 | struct device *parent); | 1000 | struct device *parent); |
diff --git a/include/drm/drm_gem.h b/include/drm/drm_gem.h new file mode 100644 index 000000000000..1e6ae1458f7a --- /dev/null +++ b/include/drm/drm_gem.h | |||
| @@ -0,0 +1,183 @@ | |||
| 1 | #ifndef __DRM_GEM_H__ | ||
| 2 | #define __DRM_GEM_H__ | ||
| 3 | |||
| 4 | /* | ||
| 5 | * GEM Graphics Execution Manager Driver Interfaces | ||
| 6 | * | ||
| 7 | * Copyright 1999 Precision Insight, Inc., Cedar Park, Texas. | ||
