]> git.kernelconcepts.de Git - karo-tx-linux.git/commitdiff
drm: Extract <drm/drm_gem.h>
authorDaniel Vetter <daniel.vetter@ffwll.ch>
Tue, 23 Sep 2014 13:46:53 +0000 (15:46 +0200)
committerDave Airlie <airlied@redhat.com>
Wed, 24 Sep 2014 01:43:41 +0000 (11:43 +1000)
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>
22 files changed:
drivers/gpu/drm/armada/armada_gem.h
drivers/gpu/drm/ast/ast_drv.h
drivers/gpu/drm/bochs/bochs.h
drivers/gpu/drm/cirrus/cirrus_drv.h
drivers/gpu/drm/drm_gem.c
drivers/gpu/drm/drm_info.c
drivers/gpu/drm/drm_prime.c
drivers/gpu/drm/exynos/exynos_drm_gem.h
drivers/gpu/drm/gma500/gtt.h
drivers/gpu/drm/i915/i915_drv.h
drivers/gpu/drm/mgag200/mgag200_drv.h
drivers/gpu/drm/msm/msm_drv.h
drivers/gpu/drm/nouveau/nouveau_bo.h
drivers/gpu/drm/omapdrm/omap_drv.h
drivers/gpu/drm/qxl/qxl_drv.h
drivers/gpu/drm/radeon/radeon.h
drivers/gpu/drm/radeon/radeon_drv.c
drivers/gpu/drm/tegra/gem.h
drivers/gpu/drm/udl/udl_drv.h
include/drm/drmP.h
include/drm/drm_gem.h [new file with mode: 0644]
include/drm/drm_gem_cma_helper.h

index 00b6cd461a03c9c1caf91b7af5264adf46c8a91e..b000ea3a829af66ca88cbaf1d314267d95623e33 100644 (file)
@@ -8,6 +8,8 @@
 #ifndef ARMADA_GEM_H
 #define ARMADA_GEM_H
 
+#include <drm/drm_gem.h>
+
 /* GEM */
 struct armada_gem_object {
        struct drm_gem_object   obj;
index 7485ff945ca9cff5a0862655c44aa5931ad00989..86205a28e56b79ceeb247949343f7117a08c393c 100644 (file)
@@ -36,6 +36,8 @@
 #include <drm/ttm/ttm_memory.h>
 #include <drm/ttm/ttm_module.h>
 
+#include <drm/drm_gem.h>
+
 #include <linux/i2c.h>
 #include <linux/i2c-algo-bit.h>
 
index 4f6e7b3a36359c8beeb5882d9d49a6e2f4a257c8..71f2687fc3ccc44fff4dd555cdfac7dd9f63d2b9 100644 (file)
@@ -7,6 +7,8 @@
 #include <drm/drm_crtc_helper.h>
 #include <drm/drm_fb_helper.h>
 
+#include <drm/drm_gem.h>
+
 #include <ttm/ttm_bo_driver.h>
 #include <ttm/ttm_page_alloc.h>
 
index dd2cfc9024aa3be943c683773bb8b88c5d365f93..d44e69daa23966c0e2f38332069a81cc24070d0a 100644 (file)
@@ -21,6 +21,8 @@
 #include <drm/ttm/ttm_memory.h>
 #include <drm/ttm/ttm_module.h>
 
+#include <drm/drm_gem.h>
+
 #define DRIVER_AUTHOR          "Matthew Garrett"
 
 #define DRIVER_NAME            "cirrus"
index f9af785415057c20e9a8ec32d2ea57c210a92e0c..cd45e45e2cced25944fe73ff2dd84b193f9f36cf 100644 (file)
@@ -38,6 +38,7 @@
 #include <linux/dma-buf.h>
 #include <drm/drmP.h>
 #include <drm/drm_vma_manager.h>
+#include <drm/drm_gem.h>
 #include "drm_internal.h"
 
 /** @file drm_gem.c
index 0780541f7935812e36ce8bda9c62081fa4748d04..51efebd434f302d61134c2eb384935ef4c1b2521 100644 (file)
@@ -35,6 +35,8 @@
 
 #include <linux/seq_file.h>
 #include <drm/drmP.h>
+#include <drm/drm_gem.h>
+
 #include "drm_legacy.h"
 
 /**
index 2807a771f505628a58a6e071c69ec837db957ca1..7826de9da2761f32ac6fa4f2f177ede8681cd18d 100644 (file)
@@ -29,6 +29,8 @@
 #include <linux/export.h>
 #include <linux/dma-buf.h>
 #include <drm/drmP.h>
+#include <drm/drm_gem.h>
+
 #include "drm_internal.h"
 
 /*
index 09d021bbccf5c5437f883b10a0d613751781765b..ec58fe9c40df5814da0e10ebc95d6186bf6fbb2e 100644 (file)
@@ -12,6 +12,8 @@
 #ifndef _EXYNOS_DRM_GEM_H_
 #define _EXYNOS_DRM_GEM_H_
 
+#include <drm/drm_gem.h>
+
 #define to_exynos_gem_obj(x)   container_of(x,\
                        struct exynos_drm_gem_obj, base)
 
index f5860a739bd8551fa60868b09ab61bb74b4c0edf..cdbb350c9d5d2b23c3272ac908163e8b6610677d 100644 (file)
@@ -21,6 +21,7 @@
 #define _PSB_GTT_H_
 
 #include <drm/drmP.h>
+#include <drm/drm_gem.h>
 
 /* This wants cleaning up with respect to the psb_dev and un-needed stuff */
 struct psb_gtt {
index 88a8b72b553e8e0e46e8692f56569d6bf2c0d148..19c0dd8e255e720acb96a114848d2ba641b7f07c 100644 (file)
@@ -43,6 +43,7 @@
 #include <linux/i2c-algo-bit.h>
 #include <drm/intel-gtt.h>
 #include <drm/drm_legacy.h> /* for struct drm_dma_handle */
+#include <drm/drm_gem.h>
 #include <linux/backlight.h>
 #include <linux/hashtable.h>
 #include <linux/intel-iommu.h>
index c03e347f3ffdf1781cbf831967be8b4239cb2bf9..e9eea1d4e7c3bff677d3b947d959685c7aa210cf 100644 (file)
@@ -22,6 +22,8 @@
 #include <drm/ttm/ttm_memory.h>
 #include <drm/ttm/ttm_module.h>
 
+#include <drm/drm_gem.h>
+
 #include <linux/i2c.h>
 #include <linux/i2c-algo-bit.h>
 
index 8a2c5fd0893e07f824b46e2d2d7528e96eca2ace..afaafd42dee739e44b7dd541eb1323defd2da5e7 100644 (file)
@@ -51,6 +51,7 @@ static inline struct device *msm_iommu_get_ctx(const char *ctx_name)
 #include <drm/drm_crtc_helper.h>
 #include <drm/drm_fb_helper.h>
 #include <drm/msm_drm.h>
+#include <drm/drm_gem.h>
 
 struct msm_kms;
 struct msm_gpu;
index ae95b2d43b3687ffcce6f5b86212d76acf7e5e14..f238def41a9266f122022224662e5f9a431c8c7f 100644 (file)
@@ -1,6 +1,8 @@
 #ifndef __NOUVEAU_BO_H__
 #define __NOUVEAU_BO_H__
 
+#include <drm/drm_gem.h>
+
 struct nouveau_channel;
 struct nouveau_fence;
 struct nouveau_vma;
index 84d73a61b34b7fad41973f8a0f3051b799928c87..60e47b33c8017a788669bd604795438d63794648 100644 (file)
@@ -26,6 +26,7 @@
 #include <drm/drmP.h>
 #include <drm/drm_crtc_helper.h>
 #include <drm/omap_drm.h>
+#include <drm/drm_gem.h>
 #include <linux/platform_data/omap_drm.h>
 
 
index d75c0a9f674f2ff785875af91ad5b01739d91778..ff0772728eb05c3eb3656c036aa1148c119087f8 100644 (file)
@@ -43,6 +43,8 @@
 #include <ttm/ttm_placement.h>
 #include <ttm/ttm_module.h>
 
+#include <drm/drm_gem.h>
+
 /* just for ttm_validate_buffer */
 #include <ttm/ttm_execbuf_util.h>
 
index 82b0e11ade8972091bd4199c5a916e614a13bf4d..ef91ebb7c671981141f33f928c107aff52639586 100644 (file)
@@ -74,6 +74,8 @@
 #include <ttm/ttm_module.h>
 #include <ttm/ttm_execbuf_util.h>
 
+#include <drm/drm_gem.h>
+
 #include "radeon_family.h"
 #include "radeon_mode.h"
 #include "radeon_reg.h"
index dd082049fd5b834ce35a53511902307f47193ab5..de108427a19745246bb171f5ce714702384426e8 100644 (file)
@@ -38,6 +38,8 @@
 #include <linux/module.h>
 #include <linux/pm_runtime.h>
 #include <linux/vga_switcheroo.h>
+#include <drm/drm_gem.h>
+
 #include "drm_crtc_helper.h"
 /*
  * KMS wrapper.
index 43a25c853357d4e9b2d51b2049b8a12794bfc714..6538b56780c2a916e817d44080e952c37bba8a89 100644 (file)
@@ -15,6 +15,7 @@
 
 #include <drm/drm.h>
 #include <drm/drmP.h>
+#include <drm/drm_gem.h>
 
 #define TEGRA_BO_BOTTOM_UP (1 << 0)
 
index 51e10ee77f399f0c433ec5fe1fe43e4e2af114da..c7490a2489a750c2bc884761300b6b324c5b572a 100644 (file)
@@ -15,6 +15,7 @@
 #define UDL_DRV_H
 
 #include <linux/usb.h>
+#include <drm/drm_gem.h>
 
 #define DRIVER_NAME            "udl"
 #define DRIVER_DESC            "DisplayLink"
index 6656fd7d64d462f82067a63afb18f024cf881358..d2c2b7f3a4e253bfafbb3fca355c13ba574d5208 100644 (file)
@@ -82,6 +82,7 @@ struct drm_agp_head;
 struct drm_local_map;
 struct drm_device_dma;
 struct drm_dma_handle;
+struct drm_gem_object;
 
 struct device_node;
 struct videomode;
@@ -330,93 +331,6 @@ struct drm_lock_data {
        int idle_has_lock;
 };
 
-/**
- * This structure defines the drm_mm memory object, which will be used by the
- * DRM for its buffer objects.
- */
-struct drm_gem_object {
-       /** Reference count of this object */
-       struct kref refcount;
-
-       /**
-        * handle_count - gem file_priv handle count of this object
-        *
-        * Each handle also holds a reference. Note that when the handle_count
-        * drops to 0 any global names (e.g. the id in the flink namespace) will
-        * be cleared.
-        *
-        * Protected by dev->object_name_lock.
-        * */
-       unsigned handle_count;
-
-       /** Related drm device */
-       struct drm_device *dev;
-
-       /** File representing the shmem storage */
-       struct file *filp;
-
-       /* Mapping info for this object */
-       struct drm_vma_offset_node vma_node;
-
-       /**
-        * Size of the object, in bytes.  Immutable over the object's
-        * lifetime.
-        */
-       size_t size;
-
-       /**
-        * Global name for this object, starts at 1. 0 means unnamed.
-        * Access is covered by the object_name_lock in the related drm_device
-        */
-       int name;
-
-       /**
-        * Memory domains. These monitor which caches contain read/write data
-        * related to the object. When transitioning from one set of domains
-        * to another, the driver is called to ensure that caches are suitably
-        * flushed and invalidated
-        */
-       uint32_t read_domains;
-       uint32_t write_domain;
-
-       /**
-        * While validating an exec operation, the
-        * new read/write domain values are computed here.
-        * They will be transferred to the above values
-        * at the point that any cache flushing occurs
-        */
-       uint32_t pending_read_domains;
-       uint32_t pending_write_domain;
-
-       /**
-        * dma_buf - dma buf associated with this GEM object
-        *
-        * Pointer to the dma-buf associated with this gem object (either
-        * through importing or exporting). We break the resulting reference
-        * loop when the last gem handle for this object is released.
-        *
-        * Protected by obj->object_name_lock
-        */
-       struct dma_buf *dma_buf;
-
-       /**
-        * import_attach - dma buf attachment backing this object
-        *
-        * Any foreign dma_buf imported as a gem object has this set to the
-        * attachment point for the device. This is invariant over the lifetime
-        * of a gem object.
-        *
-        * The driver's ->gem_free_object callback is responsible for cleaning
-        * up the dma_buf attachment and references acquired at import time.
-        *
-        * Note that the drm gem/prime core does not depend upon drivers setting
-        * this field any more. So for drivers where this doesn't make sense
-        * (e.g. virtual devices or a displaylink behind an usb bus) they can
-        * simply leave it as NULL.
-        */
-       struct dma_buf_attachment *import_attach;
-};
-
 /**
  * struct drm_master - drm master structure
  *
@@ -1073,10 +987,6 @@ extern int drm_prime_sg_to_page_addr_arrays(struct sg_table *sgt, struct page **
 extern struct sg_table *drm_prime_pages_to_sg(struct page **pages, int nr_pages);
 extern void drm_prime_gem_destroy(struct drm_gem_object *obj, struct sg_table *sg);
 
-int drm_gem_dumb_destroy(struct drm_file *file,
-                        struct drm_device *dev,
-                        uint32_t handle);
-
 
 extern struct drm_dma_handle *drm_pci_alloc(struct drm_device *dev, size_t size,
                                            size_t align);
@@ -1085,62 +995,6 @@ extern void drm_pci_free(struct drm_device *dev, struct drm_dma_handle * dmah);
                               /* sysfs support (drm_sysfs.c) */
 extern void drm_sysfs_hotplug_event(struct drm_device *dev);
 
-/* Graphics Execution Manager library functions (drm_gem.c) */
-void drm_gem_object_release(struct drm_gem_object *obj);
-void drm_gem_object_free(struct kref *kref);
-int drm_gem_object_init(struct drm_device *dev,
-                       struct drm_gem_object *obj, size_t size);
-void drm_gem_private_object_init(struct drm_device *dev,
-                                struct drm_gem_object *obj, size_t size);
-void drm_gem_vm_open(struct vm_area_struct *vma);
-void drm_gem_vm_close(struct vm_area_struct *vma);
-int drm_gem_mmap_obj(struct drm_gem_object *obj, unsigned long obj_size,
-                    struct vm_area_struct *vma);
-int drm_gem_mmap(struct file *filp, struct vm_area_struct *vma);
-
-static inline void
-drm_gem_object_reference(struct drm_gem_object *obj)
-{
-       kref_get(&obj->refcount);
-}
-
-static inline void
-drm_gem_object_unreference(struct drm_gem_object *obj)
-{
-       if (obj != NULL)
-               kref_put(&obj->refcount, drm_gem_object_free);
-}
-
-static inline void
-drm_gem_object_unreference_unlocked(struct drm_gem_object *obj)
-{
-       if (obj && !atomic_add_unless(&obj->refcount.refcount, -1, 1)) {
-               struct drm_device *dev = obj->dev;
-
-               mutex_lock(&dev->struct_mutex);
-               if (likely(atomic_dec_and_test(&obj->refcount.refcount)))
-                       drm_gem_object_free(&obj->refcount);
-               mutex_unlock(&dev->struct_mutex);
-       }
-}
-
-int drm_gem_handle_create(struct drm_file *file_priv,
-                         struct drm_gem_object *obj,
-                         u32 *handlep);
-int drm_gem_handle_delete(struct drm_file *filp, u32 handle);
-
-
-void drm_gem_free_mmap_offset(struct drm_gem_object *obj);
-int drm_gem_create_mmap_offset(struct drm_gem_object *obj);
-int drm_gem_create_mmap_offset_size(struct drm_gem_object *obj, size_t size);
-
-struct page **drm_gem_get_pages(struct drm_gem_object *obj);
-void drm_gem_put_pages(struct drm_gem_object *obj, struct page **pages,
-               bool dirty, bool accessed);
-
-struct drm_gem_object *drm_gem_object_lookup(struct drm_device *dev,
-                                            struct drm_file *filp,
-                                            u32 handle);
 
 struct drm_device *drm_dev_alloc(struct drm_driver *driver,
                                 struct device *parent);
diff --git a/include/drm/drm_gem.h b/include/drm/drm_gem.h
new file mode 100644 (file)
index 0000000..1e6ae14
--- /dev/null
@@ -0,0 +1,183 @@
+#ifndef __DRM_GEM_H__
+#define __DRM_GEM_H__
+
+/*
+ * GEM Graphics Execution Manager Driver Interfaces
+ *
+ * Copyright 1999 Precision Insight, Inc., Cedar Park, Texas.
+ * Copyright 2000 VA Linux Systems, Inc., Sunnyvale, California.
+ * Copyright (c) 2009-2010, Code Aurora Forum.
+ * All rights reserved.
+ * Copyright © 2014 Intel Corporation
+ *   Daniel Vetter <daniel.vetter@ffwll.ch>
+ *
+ * Author: Rickard E. (Rik) Faith <faith@valinux.com>
+ * Author: Gareth Hughes <gareth@valinux.com>
+ *
+ * Permission is hereby granted, free of charge, to any person obtaining a
+ * copy of this software and associated documentation files (the "Software"),
+ * to deal in the Software without restriction, including without limitation
+ * the rights to use, copy, modify, merge, publish, distribute, sublicense,
+ * and/or sell copies of the Software, and to permit persons to whom the
+ * Software is furnished to do so, subject to the following conditions:
+ *
+ * The above copyright notice and this permission notice (including the next
+ * paragraph) shall be included in all copies or substantial portions of the
+ * Software.
+ *
+ * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
+ * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
+ * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.  IN NO EVENT SHALL
+ * VA LINUX SYSTEMS AND/OR ITS SUPPLIERS BE LIABLE FOR ANY CLAIM, DAMAGES OR
+ * OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE,
+ * ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR
+ * OTHER DEALINGS IN THE SOFTWARE.
+ */
+
+/**
+ * This structure defines the drm_mm memory object, which will be used by the
+ * DRM for its buffer objects.
+ */
+struct drm_gem_object {
+       /** Reference count of this object */
+       struct kref refcount;
+
+       /**
+        * handle_count - gem file_priv handle count of this object
+        *
+        * Each handle also holds a reference. Note that when the handle_count
+        * drops to 0 any global names (e.g. the id in the flink namespace) will
+        * be cleared.
+        *
+        * Protected by dev->object_name_lock.
+        * */
+       unsigned handle_count;
+
+       /** Related drm device */
+       struct drm_device *dev;
+
+       /** File representing the shmem storage */
+       struct file *filp;
+
+       /* Mapping info for this object */
+       struct drm_vma_offset_node vma_node;
+
+       /**
+        * Size of the object, in bytes.  Immutable over the object's
+        * lifetime.
+        */
+       size_t size;
+
+       /**
+        * Global name for this object, starts at 1. 0 means unnamed.
+        * Access is covered by the object_name_lock in the related drm_device
+        */
+       int name;
+
+       /**
+        * Memory domains. These monitor which caches contain read/write data
+        * related to the object. When transitioning from one set of domains
+        * to another, the driver is called to ensure that caches are suitably
+        * flushed and invalidated
+        */
+       uint32_t read_domains;
+       uint32_t write_domain;
+
+       /**
+        * While validating an exec operation, the
+        * new read/write domain values are computed here.
+        * They will be transferred to the above values
+        * at the point that any cache flushing occurs
+        */
+       uint32_t pending_read_domains;
+       uint32_t pending_write_domain;
+
+       /**
+        * dma_buf - dma buf associated with this GEM object
+        *
+        * Pointer to the dma-buf associated with this gem object (either
+        * through importing or exporting). We break the resulting reference
+        * loop when the last gem handle for this object is released.
+        *
+        * Protected by obj->object_name_lock
+        */
+       struct dma_buf *dma_buf;
+
+       /**
+        * import_attach - dma buf attachment backing this object
+        *
+        * Any foreign dma_buf imported as a gem object has this set to the
+        * attachment point for the device. This is invariant over the lifetime
+        * of a gem object.
+        *
+        * The driver's ->gem_free_object callback is responsible for cleaning
+        * up the dma_buf attachment and references acquired at import time.
+        *
+        * Note that the drm gem/prime core does not depend upon drivers setting
+        * this field any more. So for drivers where this doesn't make sense
+        * (e.g. virtual devices or a displaylink behind an usb bus) they can
+        * simply leave it as NULL.
+        */
+       struct dma_buf_attachment *import_attach;
+};
+
+void drm_gem_object_release(struct drm_gem_object *obj);
+void drm_gem_object_free(struct kref *kref);
+int drm_gem_object_init(struct drm_device *dev,
+                       struct drm_gem_object *obj, size_t size);
+void drm_gem_private_object_init(struct drm_device *dev,
+                                struct drm_gem_object *obj, size_t size);
+void drm_gem_vm_open(struct vm_area_struct *vma);
+void drm_gem_vm_close(struct vm_area_struct *vma);
+int drm_gem_mmap_obj(struct drm_gem_object *obj, unsigned long obj_size,
+                    struct vm_area_struct *vma);
+int drm_gem_mmap(struct file *filp, struct vm_area_struct *vma);
+
+static inline void
+drm_gem_object_reference(struct drm_gem_object *obj)
+{
+       kref_get(&obj->refcount);
+}
+
+static inline void
+drm_gem_object_unreference(struct drm_gem_object *obj)
+{
+       if (obj != NULL)
+               kref_put(&obj->refcount, drm_gem_object_free);
+}
+
+static inline void
+drm_gem_object_unreference_unlocked(struct drm_gem_object *obj)
+{
+       if (obj && !atomic_add_unless(&obj->refcount.refcount, -1, 1)) {
+               struct drm_device *dev = obj->dev;
+
+               mutex_lock(&dev->struct_mutex);
+               if (likely(atomic_dec_and_test(&obj->refcount.refcount)))
+                       drm_gem_object_free(&obj->refcount);
+               mutex_unlock(&dev->struct_mutex);
+       }
+}
+
+int drm_gem_handle_create(struct drm_file *file_priv,
+                         struct drm_gem_object *obj,
+                         u32 *handlep);
+int drm_gem_handle_delete(struct drm_file *filp, u32 handle);
+
+
+void drm_gem_free_mmap_offset(struct drm_gem_object *obj);
+int drm_gem_create_mmap_offset(struct drm_gem_object *obj);
+int drm_gem_create_mmap_offset_size(struct drm_gem_object *obj, size_t size);
+
+struct page **drm_gem_get_pages(struct drm_gem_object *obj);
+void drm_gem_put_pages(struct drm_gem_object *obj, struct page **pages,
+               bool dirty, bool accessed);
+
+struct drm_gem_object *drm_gem_object_lookup(struct drm_device *dev,
+                                            struct drm_file *filp,
+                                            u32 handle);
+int drm_gem_dumb_destroy(struct drm_file *file,
+                        struct drm_device *dev,
+                        uint32_t handle);
+
+#endif /* __DRM_GEM_H__ */
index 2a3cea91606da6f568f249b85f89130f8f7e89d8..42f11f3a8d39c1945b0be16d6380cd9bb9b979dc 100644 (file)
@@ -2,6 +2,7 @@
 #define __DRM_GEM_CMA_HELPER_H__
 
 #include <drm/drmP.h>
+#include <drm/drm_gem.h>
 
 struct drm_gem_cma_object {
        struct drm_gem_object base;